Item12703: Attached file will be destroyed when uploading... but when usind upload inside wikieditor the file isn't corrupted
Priority: Normal
Current State: Closed
Released In: n/a
Target Release: n/a
Attached files will be destroyed when using "Manage Attachments" (.../foswiki/bin/attach/Main/...) but when usind upload inside wikieditor the file isn't corrupted
--
RonnyLangrock - 20 Dec 2013
Could you describe a bit more exactly how to recreate the issue?
Thanks.
--
GeorgeClark - 20 Dec 2013
Okay i will try...
I'm using foswiki 1.1.9 (upgraded from 1.1.8) running on a Windows 2003 server with Apache 2.4.6, PHP 5.4.22 and
ActiveState Perl 5.16.3.1603.
The following Plug-Ins are installed:
- TWikiCompatibilityPlugin (1.1.2, v1.1.2): Add TWiki personality to Foswiki
- SpreadSheetPlugin (1.1.7, v1.1.7): Add spreadsheet calculations like "$SUM($ABOVE())" to Foswiki tables and other topic text
- AutoViewTemplatePlugin (2012-12-16, v1.1.7): Automatically sets VIEW_TEMPLATE and EDIT_TEMPLATE
- BreadCrumbsPlugin (2.50, 2.50): A flexible way to display breadcrumbs navigation
- CommentPlugin (1.1.6, v1.1.6): Quickly post comments to a page without an edit/save cycle
- CompareRevisionsAddonPlugin (1.1.11, v1.1.11):
- DBCachePlugin (30 Aug 2013, v5.4.3): Lightweighted frontend to the DBCacheContrib
- EditTablePlugin (4.43, 4.43): Edit tables using edit fields, date pickers and drop down boxes
- FilterPlugin (3.10, $Rev: 15048 (2012-06-19) $): Substitute and extract information from content by using regular expressions
- FlexFormPlugin (2.81, 2.81): Flexible way to render DataForms
- FlexWebListPlugin (1.71, 1.71): Flexible way to display hierarchical weblists
- GenPDFAddOnPlugin (1.3, 1.3): GenPDFAddOnPlugin helper plugin for GenPDFAddOn renders the %GENPDF% tag
- HistoryPlugin (1.11, 1.11): Shows a complete history of a topic
- HolidaylistPlugin (2.001, $Rev: 14328 (2012-03-15) $): Create a table with a list of people on holidays
- ImagePlugin (08 Aug 2013, 3.11): Image and thumbnail services to display and alignment images using an easy syntax
- InterwikiPlugin (1.1.7, v1.1.7): Link ExternalSite:Page text to external sites based on aliases defined in a rules topic
- JQueryPlugin (4.91, 4.91): jQuery JavaScript library for Foswiki
- MailerContribPlugin (2.5.3, v2.5.3): Supports e-mail notification of changes
- MimeIconPlugin (1.20, 1.20): Icon sets for mimetypes
- NatEditPlugin (07 Aug 2013, 7.10): A Wikiwyg Editor
- NatSkinPlugin (3.99_007, 3.99_007): Support plugin for NatSkin
- PageOptimizerPlugin (0.10, 0.10): Optimize html markup, as well as js and css
- PreferencesPlugin (1.1.5, v1.1.5): Allows editing of preferences using fields predefined in a form
- RenderListPlugin (2.2.7, v2.2.7): Render bullet lists in a variety of formats
- RenderPlugin (3.20, 3.20): Render WikiApplications asynchronously
- SetVariablePlugin (2.32, 2.32): Flexible handling of topic variables
- SlideShowPlugin (2.1.6, v2.1.6): Create web based presentations based on topics with headings
- SmiliesPlugin (28 Nov 2012, v1.1.6): Render smilies like smile as icons
- TablePlugin (1.142, 1.142): Control attributes of tables and sorting of table columns
- TinyMCEPlugin (1.2.9, v1.2.9): Integration of the Tiny MCE WYSIWYG Editor
- TopicInteractionPlugin (3.41, 3.41): Improved interaction with attachments and DataForms
- TrashPlugin (1.01, 1.01): Maintain the Trash web
- TwistyPlugin (1.6.18, v1.6.18): Twisty section Javascript library to open/close content dynamically
- WebLinkPlugin (1.30, 1.30): A parametrized %WEB macro
- WysiwygPlugin (16 May 2013, v1.1.16): Translator framework for WYSIWYG editors
Now i've two options to attach files to my articles. I can use the build-in function inside the wikieditor or i can use directly the option in the menu in the end of each article (Edit: Attach files and images).
If i use the second option, the files i'm trying to attach will be destroyed (in my case *.pdf) but when i use the upload option inside the wikieditor the files are okay.
--
RonnyLangrock - 06 Jan 2014
Hi Ronny. What's your SKIN setting? Did you enable the UI part of
TopicInteractionPlugin as described
here? Note that
TopicInteractionPlugin uses a different backend (not
/foswiki/bin/attach
) to upload files...
Any example pdf to test with?
--
MichaelDaum - 06 Jan 2014
Hey Michael,
my actual Skin Settings are the following:
Set SKIN = metacomment, nat
Set DISPLAYCOMMENTS = on
Set COMMENTFORMAT = insidetab
Set NATSKIN_SIDEBAR = right
Set NATSKIN_MENU = on
Set NATSKIN_LAYOUT = bordered
If tried:
Set SKIN = topicinteraction, metacomment, nat
Set DISPLAYCOMMENTS = on
Set COMMENTFORMAT = insidetab
Set NATSKIN_SIDEBAR = right
Set NATSKIN_MENU = on
Set NATSKIN_LAYOUT = bordered
after your advise, but when i'm running this settings no attachment is shown and it has the same affect on files while uploading them...
You can try any pdf, they aren't special ones
--
RonnyLangrock - 06 Jan 2014
Just
SKIN = nat
is sufficient. The other prefixes (metacomment, topicinteraction, etc) are only required for
PatternSkin.
But that put aside, I wonder which "Manage Attachments" dialog you are using. Have you got a screenshot of it?
--
MichaelDaum - 06 Jan 2014
It would also be good to understand in what way the pdf is corrupted. Is it truncated, completely unreadable, wrong file attached, incorrectly encoded, uploaded as text vs. binary? There are a lot of things that can go wrong.
What is your locale / character set configured as? (Please get the following from
lib/LocalSite.cfg
)
$Foswiki::cfg{UseLocale} = ;
$Foswiki::cfg{Site}{Locale} = ;
$Foswiki::cfg{Site}{CharSet} = ;
--
GeorgeClark - 06 Jan 2014
I added some Screenshots...
- 005 - show the menu point
- 006 - "Manage Attachments" dialog
- 007 - Error Message (File was correct before uploading!)
Actual configuration:
$Foswiki::cfg{UseLocale} = 0;
$Foswiki::cfg{Site}{Locale} = 'en_US.ISO-8859-1';
$Foswiki::cfg{Site}{CharSet} = 'iso-8859-1';
--
RonnyLangrock - 07 Jan 2014
Which browser did you use to upload the PDF?
What's the file-system underneath your Foswiki? Oh I see you've installed it under Windows.
Can you reproduce the error on
http://demo.michaeldaumconsulting.com?
I've assigned the error to the
TopicInteractionPlugin installed on your setup.
Unfortunately I can't reproduce the error as I never use a Windows machine for Foswiki. I'd strongly recommend to install Foswiki on a Linux machine.
Windows is:
- highly untested running Foswiki
- is a nightmare of its own running perl under utf-8
- more expensive to set up
- harder to maintain long term
- is no 24/7 operating system showing lower average uptime rates
- more vulnerable to security breaches
- delivering a slower performance
- requiring more expensive hardware
- not feature-equivalent with a comparable Linux install
So why should you do this? The only reason people still use Windows as a server operating system is:
- politics
--
MichaelDaum - 07 Jan 2014
Normally I use the latest Firefox, but i've also tried IE and Chrome.
I cannot reproduce the error on your page.
I'm in the same opinion, which belongs to server operating systems, but i'm in a corporate infrastructure, where i have to use a windows server :-/ (if i could choose my prefered server system i would use debian like in private, but i'm not allowed to)
--
RonnyLangrock - 07 Jan 2014
Not sure how I could help you on this one without being able to repro it.
--
MichaelDaum - 07 Jan 2014
Have a look at utf-8_demo.zip it contains an utf-8 demo text file, which i used to test.
when i upload the *.txt file it remains the same, but when i rename the same file to *.pdf and upload this, i have the effect that the file isn't the same any more... but have a look at your self when you open them with i.e. notepad++.
--
RonnyLangrock - 07 Jan 2014
The files in the attached zip have all different line-end encoding, which is a common problem under Windows.
- UTF-8-demo.txt: UTF-8 Unicode English text
- UTF-8-demo.txt.after_upload.pdf: UTF-8 Unicode English text, with CRLF, CR line terminators
- UTF-8-demo.txt.before_upload.pdf: UTF-8 Unicode English text, with CRLF line terminators
It seems to be changing encoding as part of the upload. Below patch forces the file handler into binary mode. Have a try and let me know so that I can push out a new release:
--- lib/Foswiki/Plugins/TopicInteractionPlugin/Action/UploadAttachment.pm (revision 17216)
+++ lib/Foswiki/Plugins/TopicInteractionPlugin/Action/UploadAttachment.pm (working copy)
@@ -84,7 +84,7 @@
appendFile($tmpFileName, $data);
} else {
Foswiki::Plugins::TopicInteractionPlugin::Core::writeDebug("saving to $tmpFileName");
- Foswiki::Func::saveFile($tmpFileName, $data);
+ saveFile($tmpFileName, $data);
}
# end of transaction
@@ -171,7 +171,20 @@
unless (open($FILE, '>>', $name)) {
die "Can't append to $name - $!\n";
}
+ binmode($FILE);
print $FILE $text;
close($FILE);
}
+
+sub saveFile {
+ my ($name, $text) = @_;
+ my $FILE;
+ unless (open($FILE, '>', $name)) {
+ die "Can't create file $name - $!\n";
+ }
+ binmode($FILE);
+ print $FILE $text;
+ close($FILE);
+}
+
--
MichaelDaum - 08 Jan 2014
I can confirm that it now works
--
RonnyLangrock - 08 Jan 2014
Fix released in v3.43
--
MichaelDaum - 08 Jan 2014