Tags:
create new tag
, view all tags

BatchUploadPluginDev Discussion: Page for developer collaboration, enhancement requests, patches and improved versions on BatchUploadPlugin contributed by the TWikiCommunity.
• Please let us know what you think of this extension.
• For support, check the existing questions, or ask a new support question in the Support web!
• Please report bugs below

Feedback on the BatchUploadPlugin

NB. This could be a touch premature... I will test this upload in a couple of hours!

-- MartinCleaver - 31 Oct 2004

Martin, I did some editing on Plugin topic. http://TWiki.org/cgi-bin/rdiff/Plugins/BatchUploadPlugin?rev1=1.2&rev2=1.1&render=debug

Also, could you measure and document the Plugin Benchmarks?

-- PeterThoeny - 01 Nov 2004

  1. Thanks
  2. I believe Benchmarks are best administered centrally, at http://twikiplugins.sf.net; Will has agreed to test them there in due course.

-- MartinCleaver - 22 Nov 2004

Franz's comment moved to PluggableStorageForAttachments

-- MartinCleaver - 22 Nov 2004

I just wanted to add that I highly anticipate this functionality! Is this testable already?

-- ArthurClemens - 22 Nov 2004

Sorry, y. it works fine for me.

-- MartinCleaver - 22 Nov 2004

I needed to apply the following patch:

--- /proj/axaf/import/TWiki/20040902/BatchUploadPlugin/lib/TWiki/Plugins/BatchUploadPlugin.pm   2004-10-31 12:18:51.000000000 -0500
+++ lib/TWiki/Plugins/BatchUploadPlugin.pm      2004-12-03 17:43:23.221384282 -0500
@@ -88,7 +88,7 @@
                 $createLink,
 
 =cut
-sub beforeAttachmentSaveHandler ( $attrHashRef, $topic, $web ) {
+sub beforeAttachmentSaveHandler {
   my( $attrHashRef, $topic, $web ) = @_;
 
   if ($pluginEnabled) {
@@ -150,7 +150,7 @@
                               $filePath, $tmpFilename,
                               "Extracted from $originalZipName" ); 
   }
-  die "DONE! ".$error;
+  die $error if $error;
 }

The second edit was just a guess as to what really should happen.

  • Don't apply this - see below Actually, apply the first chunk but not the second. See below below.

-- DiabJerius - 03 Dec 2004

I almost forgot; BatchUploadPlugin.txt refers to a PackageForm, which doesn't exist on the standard TWiki install. TWiki refused to edit that until I manually removed the META tags.

-- DiabJerius - 03 Dec 2004

Diab - thanks for this - can you just upload your new release as a new version in the zip?

-- MartinCleaver - 04 Dec 2004

I applied the patch and things seem good. I accidently made a test ZIP file with the name all caps (caps lock on - duh!)and it attached the ZIP but did not unzip it. Desired behavior? Also .. I don't really want the zip and the individual files .. if I have the individual files - the zip is a duplication. Not a big deal - but would be "nice NOT to have" the zip as well (Hope this is the right place for these thoughts)

-- GondaEnnis - 04 Dec 2004

Thanks for the feedback - noted. If you are feeling adventurous please feel free to upload a version incorporating your suggestions. smile

-- MartinCleaver - 04 Dec 2004

Any updates? I don't want to have that zip-attachment too.

-- Kai (in an email to MartinCleaver)

Reading it again, the patch above, dieing with an error if there was one, is incorrect. Without dieing the plugin has no means to veto the upload of the zip file, so it gets put alongside the unzipped files.

As I have no immediate need to fix this I invite someone else to take this on. Alternatively a little OpenSourceFunding would certainly get my attention.

-- MartinCleaver - 14 Dec 2004

The first chunk of DiabJerius patch is valid, and should be applied. Without:

--- /proj/axaf/import/TWiki/20040902/BatchUploadPlugin/lib/TWiki/Plugins/BatchUploadPlugin.pm   2004-10-31 12:18:51.000000000 -0500
+++ lib/TWiki/Plugins/BatchUploadPlugin.pm      2004-12-03 17:43:23.221384282 -0500
@@ -88,7 +88,7 @@
                 $createLink,
 
 =cut
-sub beforeAttachmentSaveHandler ( $attrHashRef, $topic, $web ) {
+sub beforeAttachmentSaveHandler {
   my( $attrHashRef, $topic, $web ) = @_;
 
   if ($pluginEnabled) {

...you'll get many error messages in your error.log file like this one (at least on a Debian system):

[Mon Feb 14 22:47:28 2005] view: Illegal character in prototype for TWiki::Plugins::BatchUploadPlugin::beforeAttachmentSaveHandler : $attrHashRef,$topic,$web at ../lib/TWiki/Plugins/BatchUploadPlugin.pm line 91.
Illegal character in prototype for
        TWiki::Plugins::BatchUploadPlugin::beforeAttachmentSaveHandler : $attrHashRef,$topic,$web at ../lib/TWiki/Plugins/BatchUploadPlugin.pm line 91 (#1)
    (W syntax) An illegal character was found in a prototype declaration.  Legal
    characters in prototypes are $, @, %, *, ;, [, ], &, and \.

-- TobyCabot - 15 Feb 2005

Using perl 5.8.6 I get errors regarding use of uninitialized strings with the concatenation operator. I modified the code to check if a variable isn't initialized prior to use, but I didn't check every code path. The plugin needs to be updated for use with the latest stable TWiki.

Is there any way to have an option on the upload page to enable/disable the plugin, instead of an external setting?

-- PaulOgilvie - 04 May 2005

Paul - Not at present.

It occurred to me that we ought have a batch download mechanism too - so that all files can be pulled down at the same time through a zip.

-- MartinCleaver - 05 May 2005

added .zip to CVS

-- WillNorris - 27 Jun 2005

I have installed this plugin, but it doesn't appear in my list of Installed Plugins in the TWiki web. I can go directly to it, and after removing the Package Form META tag manually, I could edit it too.

However, uploading a .zip file doesn't have the desired effect, I'm just left with a zip attachment.

What are the patches above for? How are they used? Are they the answer to my problem?

-- EdMcDonagh - 02 Aug 2005

What version of TWiki are you using?

-- MartinCleaver - 02 Aug 2005

02Sep2004 - do I need to be using Dakar?

As an additional complication I manually installed CPAN:Archive::Zip, after which nothing on TWiki worked - just got a 500 internal server error with the log telling me Premature end of script headers. Non-TWiki parts of the intranet work, so I am assuming at this stage that I have somehow broken perl...

-- EdMcDonagh - 03 Aug 2005

Sounds like your manual install didn't go as well as you'd hoped! I'd reinstall perl :/

This plugin is indeed currently targeted at TWikiRelease20040902 or TWikiRelease20040901.

I hope this helps.

-- MartinCleaver - 03 Aug 2005

What is the BatchUploadPlugin _installer.pl for, and how do you use it properly?

-- ToddGrayson - 13 Sep 2005

Its just the standard BuildContrib utility that checks for prerequisites. You don't have to use it but if you do unzip the archive then run the script.

-- MartinCleaver - 13 Sep 2005

I've re-uploaded the ZIP file with the patch applied. (It killed my entire TWiki web site without it!). Currently don't have access to CVS, but I would guess this is already in it. The text above confused me a little, especially the "patch should be applied. without"... so I've attached the patch I applied on this page for reference.

Update I only did half a job the first time. I've now removed the META tags from BatchUploadPlugin.txt too. I think it should be ready to deploy directly now. (Patch file here is updated as well).

-- SteveHobbs - 23 Sep 2005

Thanks Steve. Feedback: Better to give a descriptive text in the change history, it is not clear from "updated zip with patch from BatchUploadPluginDev" what the patch does and which patch it is. Also, please use only Interwiki names (BatchUploadPluginDev points to Nirvana at a site where this Plugin is installed)

-- PeterThoeny - 23 Sep 2005

Like Paul Ogilvie (above) I also get errors regarding use of uninitialized strings with the concatenation operator in BatchUploadPlugin.pm line 222 (#1) (W uninitialized). I use perl 5.8.7 and TWiki version 02 Sep 2004, Plugin API version 1.025 on a Debian system). My perl is ok.

-- MichaelWagnerBerlin - 17 Oct 2005

Great plugin. I noticed that file names are made all lower case when unzipping and attaching. Also, I always receive a software error when the upload is finished that says "Done". It's a little unnerving (I assume this is normal behaviour).

-- ChrisPurves - 22 Dec 2005

This would be helpfull in the install instructions, but what exactly needs to be enabled? Is there a line that needs to be added to TWiki.cfg?

Thanks

-- EricHanson - 30 Mar 2006

Graghgh, I just answered my own question. I didn't read the section above installation.

-- EricHanson - 30 Mar 2006

I'm having trouble with this plugin on 4.0.2. Once installed, all uploads zips and non-zips, fail followng errors:

OopsException(attention/zero_size_upload web=>Sandbox topic=>TestImageGallery params=>cake1.jpg) ******************************** binmode() on closed filehandle F at         /var/www/twiki.worcesterapa.org/lib/TWiki/Store.pm line 900 (#1)     (W unopened) You tried binmode() on a filehandle that was never opened.     Check you control flow and number of arguments.  [Mon Apr 24 14:19:09 2006] upload: binmode() on closed filehandle F at /var/www/twiki.worcesterapa.org/lib/TWiki/Store.pm line 900. [Mon Apr 24 14:19:09 2006] upload: [Mon Apr 24 14:19:09 2006] upload: binmode() on closed filehandle F at /var/www/twiki.worcesterapa.org/lib/TWiki/Store.pm line 900. [Mon Apr 24 14:19:09 2006] upload: [Mon Apr 24 14:19:09 2006] upload: [Mon Apr 24 14:19:09 2006] upload: binmode() on closed filehandle F at /var/www/twiki.w orcesterapa.org/lib/TWiki/Store.pm line 900. 

The error messages loop and fail with a deep recursion

Deep recursion on subroutine "CGI::Carp::warn" at /usr/lib/perl5/5.8.7/diagnostics.pm line 506. 

-- GeorgeClark - 24 Apr 2006

Does this plugin work with Dakar?

-- RyanMarotz - 12 May 2006

To the Plugin maintainer: This Plugin does not seem to work in TWiki 4.0. Please consider upgrading this Plugin so that it runs on Cairo and Dakar codebase. HandlingCairoDakarPluginDifferences has more.

-- PeterThoeny - 12 May 2006

No. It does not work with Dakar.

If anyone would like to fund or donate toward this work I available for contract work.

If anyone else would like to take it over please feel free.

If at some point one of my clients wants this updated I will of course release it.

If I do release it I will release only a dakar version. It will not be a dual working version.

Thanks for your understanding.

-- MartinCleaver - 13 May 2006

I find this unfortunate for these reasons:

  • I understand that you need finacial support, but is this the right approach to abandon a non-working Plugin unless there is funding?
  • Creating a second codebase/download for Dakar makes it less convenient for the administrators
  • Many site owners do not upgrade TWiki for a long time (for various reasons), e.g. they can't benefit from new features

-- PeterThoeny - 13 May 2006

I have not abandoned it. I am just not working on it until the circumstances work for me.

Others are free to adapt this plugin. I created this iteration after TWiki:Main.DiabJerius, TWiki:Main.JohannesMartin, TWiki:Main.ThomasWeigert, TWiki:Main.RyanFreebern and TWiki:Main.VitoMiliano did the earlier revisions. TWiki:Main.SteveHobbs released a later version than me.

I don't use Cairo. If someone wants me to work against my environment in timescales that don't work for me then they are extremely welcome to provide incentive for me.

That does not need to be cash. It could be an exchange of labour.

At a systemic level the leadership needs to coach people to take over ownership for a periods of time, not chastise someone to work against their own best interests.

I wrote "ModificationPolicy: PleaseFeelFreeToModify" for a reason.

-- MartinCleaver - 13 May 2006

Is it possible to let the user choose whether or not the .zip file is unpacked and the content of the file is attached or the .zip file itself is attached to the topic? ~~~~

-- MarkusBajones - 29 Jul 2006

Not at present.

I am not currently providing free maintenance of this plugin, but you are welcome to either contract me, or someone else, or to make your own changes and contribute your changes back to the community.

-- MartinCleaver - 29 Jul 2006

I am likely to update this for TWiki4 shortly, pending scope and budget approval from a prospective client.

-- MartinCleaver - 28 Aug 2006

I got some budget approved and am working on this today. It looks a bigger job than I had hoped, but will keep everyone posted.

-- MartinCleaver - 13 Sep 2006

A Dakar version has been submitted to my client.

-- MartinCleaver - 18 Sep 2006

Great, will he/you publish it here on twiki.org too?

-- FranzJosefSilli - 18 Sep 2006

Sure, we agreed that once the client has signed off on the work it will be available for all to use.

It does not substantially change anything over the Cairo version except that it works on Dakar.

-- MartinCleaver - 18 Sep 2006

Any news on when it will be available?

-- FlorianSimatos - 12 Oct 2006

please Martin .... much of my sanity depends on this plugin

-- GondaEnnis - 25 Oct 2006

I've emailed Gonda. Florian does not have an email address public.

-- MartinCleaver - 03 Nov 2006

I have added one smile

-- FlorianSimatos - 06 Nov 2006

I've emailed Florian.

-- MartinCleaver - 09 Nov 2006

Hm, why not simply publish what you've mailed to Gonda and Florian? wink

-- FranzJosefSilli - 09 Nov 2006

I set out to install the BatchUploadPlugin but the required CPAN:Archive::Zip module itself has about a dozen pre-requisite CPAN modules. And those modules have pre-requisites, and those do too ....

How can I install all of the required CPAN modules in one go, without having to pick thru the requirements one at a time ?

-- KeithHelfrich - 13 Dec 2006

Well, after a couple of hours of guesswork, I seem to have managed to follow all of the right instructions. I've upgraded to perl 5.8.8, installed CPAN:Archive::Zip, and pushed all of this down into the CHROOT jail.

Happy to report: the BatchUploadPlugin is working correctly. smile But the %LOGON_OR_WELCOME% variable is broken now. I'm going to have to back all of this out frown Does anybody know, what is the RecommendedPerlVersion ?

-- KeithHelfrich - 13 Dec 2006

Keith, if you re-bundle the plugin to use BuildContrib, then that module will generate an installer which automatically installs all these dependencies.

I wouldn't waste time with a perl version less than 5.8 (5.008).

-- CrawfordCurrie - 15 Dec 2006

I have updated the plugin.

-- ArthurClemens - 24 Dec 2006

Thanks Arthur for picking up this plugin, this is open source spirit! smile

-- PeterThoeny - 24 Dec 2006

Does this plugin run on TWiki Sep-2004 and TWiki 4? The version-check on init suggests Sep-2004, but the topic format is TWiki 4. Please update the TestedOnTWiki form field if needed.

-- PeterThoeny - 24 Dec 2006

I expect it to run, but I couldn't test it yet.

-- ArthurClemens - 24 Dec 2006

The update does not run on the Sep-2004 release.

-- ArthurClemens - 28 Dec 2006

After installing this plugin-if you try to attach any zip, it gets expanded and individual files get attached to the topic. But many times i want to attach zip to the topic and not individual files -This must be common requirement for many users.

I think it would be good idea to add choice of expand/dont expand zip while uploading the files-some variable should be passed to the plugin.

OR

It would be good idea to seperate Batchupload interface from Attachment.

-- SopanShewale - 04 Jan 2007

Yes, Sopan. I very much agree because I too often do not want for the zip file to be expanded. I think it would be best to keep a single attachment interface and provide the user with a choice upon zipfile attachment. Doing so without skin modifications would also be nice, because sites that do not use the pattern skin would prefer to not be required to edit their skin templates.

Could the plugin ask about whether to expand the zip by using a popup ? Something like, "I see you're attaching a zip file, would you like to ... ?"

-- KeithHelfrich - 06 Jan 2007

Hi everybody,

I am setting up my Twiki site with some of your great plug-ins, but seems two of them don't like each other:

this BatchUploadPlugin vs ImageGalleryPlugin

I believe one most wanted app of this batch upload is when creating an image gallery, tens if not tons of images. Both plug-ins are otherwise great when playing solo, thanks for your efforts.

My set-up is:

Apache error log:

  • Deep recursion on subroutine "CGI::Carp::warn" at /usr/lib/perl5/5.8.6/diagnostics.pm line 506.

Please help, THANKS !!

-- EdwardTam - 12 Jan 2007

After doing couple of modifications in Store.pm, Upload.pm and templates related to attach script we could achieve Extracting Zip and attaching files to topic based on users choice using attachment api.

The modifications are done by referring BatchUpload plugin-hope I am not violating any licenses.

I have attached the zip file called MyBatchUpload.zip which contains following files.

/lib/TWiki/Store.pm
/lib/TWiki/UI/Upload.pm
/templates/attach.classic.tmpl
/templates/attach.pattern.tmpl
/templates/attach.tmpl

To install this-kindly take the backup of your lib and template directory, then unzip MyBatchUpload.zip into TWiki root. Also set Following variables in your TWikiPreferences topic.

* Batch Upload Settings
      * Set BATCHUPLOADCOMMENT = Extracted from Zip
      * Set BATCHUPLOADTEMPDIRECTORY = /tmp/Temp_Upload
      * Set BATCHUPLOADCHECKBOX =

To always keep "Batchupload checked, you need to set following:

   * Set BATCHUPLOADCHECKBOX = checked="checked"

Note /tmp/Temp_Upload directory is used to extract the files-and cleaned later

The Attachment User Interface looks as shown in this picture.

batchuploadattachmentscreen.JPG

Dependency is : Archive::Zip module

We have done similar work for Cairo release-If anyone needs it-send a mail to sopan_shewale@persistentPLEASENOSPAM.co.in

I would like to Thank my colleague ChhayaDhone for taking care of coding part. Also would like to thank Persistent for allowing us to spend time.

-- SopanShewale - 12 Jan 2007

I installed and tested MyBatchUpload on TWiki version TWiki-4.0.5, Tue, 24 Oct 2006, build 11822, Plugin API version 1.

The First test I did was uploading a zip file with BatchUpload Checked and it did went good.

The second test I did was uploading a zip file with BatchUpload not Checked and somehow the zip still got extracted.

This was logged at debug.txt

| 16 Jan 2007 - 21:44 | BatchUpload Option NOT selected
| 16 Jan 2007 - 21:44 | file test.zip is not zip file
| 16 Jan 2007 - 21:44 | - BatchUploadPlugin::beforeAttachmentSaveHandler( Sandbox.TestBatch - attachment: test.zip)
| 16 Jan 2007 - 21:44 | BatchUploadPlugin - test.zip has stack depth 0
| 16 Jan 2007 - 21:44 | BatchUploadPlugin - Created temp dir /twiki/pub/_work_areas/BatchUploadPlugin/242340403
| 16 Jan 2007 - 21:44 | BatchUploadPlugin - Trying to attach: fileName=disk_usage.txt, fileSize=461, fileDate=1168983858, fileComment=Extracted from test.zip, tmpFilename=/twiki/pub/_work_areas/BatchUploadPlugin/242340403/disk_usage.txt
| 16 Jan 2007 - 21:44 | BatchUpload Option NOT selected
| 16 Jan 2007 - 21:44 | file disk_usage.txt is not zip file
| 16 Jan 2007 - 21:44 | - BatchUploadPlugin::beforeAttachmentSaveHandler( Sandbox.TestBatch - attachment: disk_usage.txt)
| 16 Jan 2007 - 21:44 | BatchUploadPlugin - Attaching disk_usage.txt went OK
| 16 Jan 2007 - 21:44 | BatchUploadPlugin - Result stack: 0
| 16 Jan 2007 - 21:44 | - BatchUploadPlugin::initPlugin( Sandbox.TestBatch ) is OK

-- MarkPagulayan - 16 Jan 2007

My mistake-Please disable BatchUploadPlugin if you want to use the code from MyBatchUpload.zip file. I forgot to mention this-my apologies.

We also forgot to remove the debug statments (bad practice-sorry for this) in last file-I have uploaded the new file.

-- SopanShewale - 17 Jan 2007

Hi,

I had some troubles running the installer skript. This is what happend:

Can't locate Archive/Zip.pm

This module is available from the CPAN archive (http://www.cpan.org). You
can download and install it from here. The module will be installed
to wherever you configured CPAN to install to.

Would you like me to try to download and install the latest version of Archive::Zip from cpan.org? [y/n] y
CPAN: Storable loaded ok
Going to read /root/.cpan/Metadata
  Database was generated on Thu, 25 Jan 2007 11:27:47 GMT
Can't locate object method "dslip_status" via package "CPAN::Module" at BatchUploadPlugin_installer line 247, <STDIN> line 1.

Plugin Diagnostics says:

TWiki::Plugins::BatchUploadPlugin could not be loaded.  Errors were: 
Can't locate Archive/Zip.pm in @INC (
@INC contains: 
/myserver/twiki/lib/CPAN/lib//arch/ /myserver/twiki/lib/CPAN/lib//5.8.8/i586-linux-thread-multi/ 
/myserver/twiki/lib/CPAN/lib//5.8.8/ 
/myserver/twiki/lib/CPAN/lib// 
/myserver/twiki/lib . 
/usr/lib/perl5/5.8.8/i586-linux-thread-multi 
/usr/lib/perl5/5.8.8 /usr/lib/perl5/site_perl/5.8.8/i586-linux-thread-multi 
/usr/lib/perl5/site_perl/5.8.8 
/usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi 
/usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl) at /myserver/twiki/lib/TWiki/Plugins/BatchUploadPlugin.pm line 28.
BEGIN failed--compilation aborted at /myserver/twiki/lib/TWiki/Plugins/BatchUploadPlugin.pm line 28.
Compilation failed in require at (eval 45) line 1.
BEGIN failed--compilation aborted at (eval 45) line 1.

Any ideas what's wrong? Thanks.

-- CarloSchulz - 25 Jan 2007

CPAN's Archive:Zip is a requirement. You would be able to install this by writing the command cpan in the shell, and then install Archive::Zip.

-- ArthurClemens - 25 Jan 2007

Sweet! Thanks a lot smile

-- CarloSchulz - 29 Jan 2007

A user-friendly error message would be nice though...

-- ArthurClemens - 29 Jan 2007

Check out UploadToTWikiAddOn, it enables you to upload many files with on command, such as
uploadtotwiki.pl -l PeterThoeny -c 'Trip to Costa Rica' *.jpg http://example.com/cgi-bin/view/Albums/PhotoAlbum5

-- PeterThoeny - 13 Feb 2007

I've had a crack at patching the plugin to allow the user to disable expansion of zip files in the same way that SopanShewale provided with MyBatchUpload.zip. I think it is preferable to do this within the plugin rather than by modifying the TWiki core. Have a look at BatchUploadPlugin_zip_option.patch and let me know if I've gone about this the right way (still fairly new to plugin development).

-- MartinRothbaum - 19 Feb 2007

Martin's approach works just fine for me, and I whole-heartedly agree that patching plugin code is preferable to patching the core.

Two comments: with the change, TWiki::Func::getCgiQuery is called twice in beforeAttachmentSaveHandler. So the second call can be removed, and the variable names normalized; also the template modification could be added to attach.classic.tmpl and attach.tmpl.

Thanks to Sopan and Martin for providing a much needed fix!

-- ScottHoge - 19 Feb 2007

I've rolled Martin's code change and Sopan's template change into the 20 Feb 2007 release. Thanks again.

-- ScottHoge - 20 Feb 2007

AddSanitizeAttachmentNameToTWikiFunc is now available to be implemented.

-- ArthurClemens - 18 Mar 2007

It appears I am now dependent on the form checkbox. When I don't have the checkbox the plugin will not unpack anything.

-- ArthurClemens - 21 Mar 2007

I think that in order to have both the old and the new functionality, a new cfg variable will need to be introduced. It appears that not having the checkbox in the form is the same as having the checkbox 'unchecked', as far as cgi->param is concerned.

This patch should solve the problem. The doc will have to be updated before release, however:

===================================================================
--- lib/TWiki/Plugins/BatchUploadPlugin.pm   (revision 13203)
+++ lib/TWiki/Plugins/BatchUploadPlugin.pm   (working copy)
@@ -95,8 +95,12 @@
     ) if $debug;
 
     my $cgiQuery = TWiki::Func::getCgiQuery();
-    return if ( !$pluginEnabled || !$cgiQuery->param('batchupload') );
+    return if ( !$pluginEnabled );
 
+    my $batchupload = $cgiQuery->param('batchupload') || '';
+    return if ( ( $TWiki::cfg{Plugins}{BatchUploadPlugin}{usercontrol} ) 
+                && ( $batchupload ne 'on' ) );
+
     my $attachmentName = $attrHashRef->{attachment};
 
     return if ( !isZip($attachmentName) );

-- ScottHoge - 22 Mar 2007

It does not look like this plugin checks the ATTACHFILESIZELIMIT preference. Ideally it should check this with each file it uploads, and throw an oops exception if its too big.

-- AndrewRJones - 03 May 2007

I've created a bug report for this. Bugs:Item4013.

-- ArthurClemens - 03 May 2007

The checkbox in the attach template should be placed just below the upload field, not in the properties section (an existing zipped file will not be unzipped on the server with "Change properties only").

-- ArthurClemens - 27 Aug 2007

Try as I might, I cannot get the BatchUploadPlugin to appear in the configure script. I've copied the zip file to the Twiki root directory, unzipped the package and run the install script, seemingly successfully. Permissions seem OK. We're running dakar 4.0. Please help!

-- ColinFerguson - 03 Oct 2007

Go to your TWiki.InstalledPlugins if you see any errors.

-- ArthurClemens - 03 Oct 2007

My apologies...I should have listed other debugging steps I took. I checked InstalledPlugins, but no errors appear there. Neither does BatchUploadPlugin. None of the log files in /data contain any clues. I do not have a debug.txt or a warn*.txt file. It is absolutely as if I haven't installed the plugin...but all plugin-related files appear where they are suppose to. The wiki is otherwise fully functional, with several other plugins running happily.

-- ColinFerguson - 04 Oct 2007

Did you also change the attach template to include the checkbox?

-- ArthurClemens - 04 Oct 2007

No I didn't. However, we now have the plugin appearing in the configure script...it seems we had some path confusion. Now we are getting the following error when we try and upload a zip file:

During save of Sandbox.ColinFergusonSandbox an error was found by the version control system. Please notify your TWiki administrator.  =Problem with Zip read error or not a zip file.  at /usr/share/bugzilla-2.16.7/TWiki/lib/TWiki/Plugins/BatchUploadPlugin.pm line 169.  at /usr/lib/perl5/5.8.5/CGI/Carp.pm line 319    CGI::Carp::realdie('Problem with Zip read error or not a zip file.  at /usr/share...') called at /usr/lib/perl5/5.8.5/CGI/Carp.pm line 396    CGI::Carp::die('Problem with Zip read error or not a zip file. ') called at /usr/share/bugzilla-2.16.7/TWiki/lib/TWiki/Plugins/BatchUploadPlugin.pm line 169    TWiki::Plugins::BatchUploadPlugin::updateAttachment('Sandbox', 'ColinFergusonSandbox', 'tst.zip', 'undef', '') called at /usr/share/bugzilla-2.16.7/TWiki/lib/TWiki/Plugins/BatchUploadPlugin.pm line 116    TWiki::Plugins::BatchUploadPlugin::beforeAttachmentSaveHandler('HASH(0xa9e9288)', 'ColinFergusonSandbox', 'Sandbox') called at /usr/share/bugzilla-2.16.7/TWiki/lib/TWiki/Plugin.pm line 225    TWiki::Plugin::invoke('TWiki::Plugin=HASH(0xa5c2dd8)', 'beforeAttachmentSaveHandler', 'HASH(0xa9e9288)', 'ColinFergusonSandbox', 'Sandbox') called at /usr/share/bugzilla-2.16.7/TWiki/lib/TWiki/Plugins.pm line 303    TWiki::Plugins::_dispatch('TWiki::Plugins=HASH(0x9e52170)', 'beforeAttachmentSaveHandler', 'HASH(0xa9e9288)', 'ColinFergusonSandbox', 'Sandbox') called at /usr/share/bugzilla-2.16.7/TWiki/lib/TWiki/Plugins.pm line 677    TWiki::Plugins::beforeAttachmentSaveHandler('TWiki::Plugins=HASH(0x9e52170)', 'HASH(0xa9e9288)', 'ColinFergusonSandbox', 'Sandbox') called at /usr/share/bugzilla-2.16.7/TWiki/lib/TWiki/Store.pm line 907    TWiki::Store::__ANON__() called at /usr/share/bugzilla-2.16.7/TWiki/lib/CPAN/lib///Error.pm line 387    eval {...} called at /usr/share/bugzilla-2.16.7/TWiki/lib/CPAN/lib///Error.pm line 379    Error::subs::try('CODE(0xa9d540c)', 'HASH(0xa9c606c)') called at /usr/share/bugzilla-2.16.7/TWiki/lib/TWiki/Store.pm line 965    TWiki::Store::saveAttachment('TWiki::Store=HASH(0xa3cc528)', 'Sandbox', 'ColinFergusonSandbox', 'tst.zip', 'TWiki::User=HASH(0xa81d14c)', 'HASH(0xa9d54fc)') called at /usr/share/bugzilla-2.16.7/TWiki/lib/TWiki/UI/Upload.pm line 226    TWiki::UI::Upload::__ANON__() called at /usr/share/bugzilla-2.16.7/TWiki/lib/CPAN/lib///Error.pm line 387    eval {...} called at /usr/share/bugzilla-2.16.7/TWiki/lib/CPAN/lib///Error.pm line 379    Error::subs::try('CODE(0xa9d537c)', 'HASH(0xa9d5388)') called at /usr/share/bugzilla-2.16.7/TWiki/lib/TWiki/UI/Upload.pm line 243    TWiki::UI::Upload::upload('TWiki=HASH(0x9d12d48)') called at /usr/share/bugzilla-2.16.7/TWiki/lib/TWiki/UI.pm line 97    TWiki::UI::__ANON__() called at /usr/share/bugzilla-2.16.7/TWiki/lib/CPAN/lib///Error.pm line 387    eval {...} called at /usr/share/bugzilla-2.16.7/TWiki/lib/CPAN/lib///Error.pm line 379    Error::subs::try('CODE(0xa5c5524)', 'HASH(0xa9a08f8)') called at /usr/share/bugzilla-2.16.7/TWiki/lib/TWiki/UI.pm line 146    TWiki::UI::run('CODE(0x9edf598)') called 

The zip file is a standard winzip file containing a few GIFs. Just to be sure the zip file was OK, I tried uploading the MyBatchUpload.zip file to attach to my sandbox page, and got the same type of error.

We are running Perl 5.8.5... do we need to upgrade?

-- ColinFerguson - 04 Oct 2007

Did you install CPAN:Archive::Zip ?

-- ArthurClemens - 05 Oct 2007

I believe so.

I ran this:

%perl -MCPAN -e shell

cpan1>install Archive::Zip

this seemed to download a new version of that package, but still seem to get the same error.

-- ColinFerguson - 10 Oct 2007

Could you upload the problematic zip here? I would like to test it.

-- ArthurClemens - 10 Oct 2007

The last file I've tried was the MyBatchUpload.zip file available below.

I should also point out that if I have the plug-in enabled and I try to attach a single file (for example, gif file or something), the file attaches properly but all text in the topic disappears! For this reason I have been forced to keep the plug-in disabled for now. Does this give you a clue?

-- ColinFerguson - 11 Oct 2007

On my installation it all works fine - unfortunately because I cannot give you a clue.

-- ArthurClemens - 11 Oct 2007

Colin, you should try upgrading your wiki-installation, the problem you descripe sounds like a known bug in versions previous to 4.1.2 (attach handler problem).

-- SteffenPoulsen - 11 Oct 2007

I found a small bug inside isZip function. It's identifying every filename ending with "zip" and any character before that as a zip file (ex: somefilezip).

To correct that, just edit lib/TWiki/Plugins/BatchUploadPlugin.pm and update the following line:

145c145
<     return $fileName =~ m/.zip$/;
---
>     return $fileName =~ m/\.zip$/;

-- GuilhermeGarnier - 25 Jan 2008

If you want to use the option "Do not show attachment in table" when uploading zip, the files are still shown in the table. Somebody an idea how to solve this?

-- FrederikBeun - 01 Apr 2008

Two years ago, MarkusBajones wrote:

Is it possible to let the user choose whether or not the .zip file is unpacked
 and the content of the file is attached or the .zip file itself is
 attached to the topic? 

-- MarkusBajones - 29 Jul 2006 

Are there any plans to handle this? It's the one thing that prevents my company from installing this plugin. Some people would like to upload an actul zip file... With 14,000 people, we can't make the decision for them!

-- VickiBrown - 09 Apr 2008

Vicki, this has been implemented. It needs a small template change. See instructions on the plugin page.

Of course this could be improved by showing a dialog "Hey, I notice you are uploading a zip file. Do you want me to unpack it for you?".

-- ArthurClemens - 09 Apr 2008

Thanks Arthur! I've notified our TWiki admin.

-- VickiBrown - 09 Apr 2008

Is there a new version tailored for TWiki 4.2?

-- JimmyHsiao - 30 May 2008

I just uploaded an enhanced version. The changes are also summarized in Bugs:Item5763.

-- MarkusUeberall - 10 Jul 2008

I met a problem when I use Batch upload plugin. I download BatchUploadPlugin.tgz from twiki offical site . I follow Batch upload plugin (BatchUploadPlugin.txt)document install steps. I extract the tgz file , manually move BatchUploadPlugin.pm to lib/TWiki/Plugins/ , I also changed templates/attach.pattern.tmpl and templates/attach.tmpl . I use "Configure" tool to enable "Batch Upload Plugin" function . But when I attach a zip file , the following error messages appear ...

Problem with Zip read error or not a zip file. at /userap/users/teamspace/twiki/lib/TWiki/Plugins/BatchUploadPlugin.pm line 177. at /userap/users/teamspace/twiki/lib/TWiki/Plugins/BatchUploadPlugin.pm line 177 TWiki::Plugins::BatchUploadPlugin::updateAttachment('Main', 'TestPlugin', 'pic3.zip', '', '', '', '') called at /userap/users/teamspace/twiki/lib/TWiki/Plugins/BatchUploadPlugin.pm line 120 TWiki::Plugins::BatchUploadPlugin::beforeAttachmentSaveHandler('HASH(0xb1f1af4)', 'TestPlugin', 'Main') called at /userap/users/teamspace/twiki/lib/TWiki/Plugin.pm line 266 TWiki::Plugin::invoke('TWiki::Plugin=HASH(0xad20a88)', 'beforeAttachmentSaveHandler', 'HASH(0xb1f1af4)', 'TestPlugin', 'Main') called at /userap/users/teamspace/twiki/lib/TWiki/Plugins.pm line 344 TWiki::Plugins::_dispatch('TWiki::Plugins=HASH(0xa23c004)', 'beforeAttachmentSaveHandler', 'HASH(0xb1f1af4)', 'TestPlugin', 'Main') called at /userap/users/teamspace/twiki/lib/TWiki/Plugins.pm line 742 TWiki::Plugins::beforeAttachmentSaveHandler('TWiki::Plugins=HASH(0xa23c004)', 'HASH(0xb1f1af4)', 'TestPlugin', 'Main') called at /userap/users/teamspace/twiki/lib/TWiki/Store.pm line 974 TWiki::Store::__ANON__() called at /userap/users/teamspace/twiki/lib/CPAN/lib//Error.pm line 379 eval {...} called at /userap/users/teamspace/twiki/lib/CPAN/lib//Error.pm line 371 Error::subs::try('CODE(0xb1ef058)', 'HASH(0xb1f1318)') called at /userap/users/teamspace/twiki/lib/TWiki/Store.pm line 1020 TWiki::Store::saveAttachment('TWiki::Store=HASH(0x9eac810)', 'Main', 'TestPlugin', 'pic3.zip', 'Y_bret', 'HASH(0xb1eefc8)') called at /userap/users/teamspace/twiki/lib/TWiki/UI/Upload.pm line 239 TWiki::UI::Upload::__ANON__() called at /userap/users/teamspace/twiki/lib/CPAN/lib//Error.pm line 379 eval {...} called at /userap/users/teamspace/twiki/lib/CPAN/lib//Error.pm line 371 Error::subs::try('CODE(0xb1eee6c)', 'HASH(0xb1eeecc)') called at /userap/users/teamspace/twiki/lib/TWiki/UI/Upload.pm line 258 TWiki::UI::Upload::upload('TWiki=HASH(0xa23c424)') called at /userap/users/teamspace/twiki/lib/TWiki/UI.pm line 159 TWiki::UI::__ANON__() called at /userap/users/teamspace/twiki/lib/CPAN/lib//Error.pm line 379 eval {...} called at /userap/users/teamspace/twiki/lib/CPAN/lib//Error.pm line 371 Error::subs::try('CODE(0x9e94d40)', 'HASH(0xb18d12c)') called at /userap/users/teamspace/twiki/lib/TWiki/UI.pm line 197 TWiki::UI::run('CODE(0xa23103c)') called

-- BretHuang - 27 Aug 2008

Why would that plug-in not work with Archive::Zip 1.16 instead of 1.18?

-- StephaneLenclud - 06 Oct 2008

@ -- BretHuang - 27 Aug 2008: I'm facing the same issue (Problem with Zip read error or not a zip file. at /userap/users/teamspace/twiki/lib/TWiki/Plugins/BatchUploadPlugin.pm line 177. , etcetera).

I've got the BatchUploadPlugin version 1.400; Archive-Zip 1.18 (perl) and 1.23 (site) according to my Perl Package Manager.

Running TWiki for Windows (TWiki 4.2.0, Apache 2.2, rcs, ActiveState perl 5.8) with Plugin API version 1.2 .

-- RoelofVanHemmen - 22 Oct 2008

After install BatchUploadPlugin I was getting an error when uploading zip files "Insecure dependency in chmod..." line 399.

The fix was to edit the /bin/upload file and remove the T from the line #/usr/perl -wT

might help someone smile

-- AndrewRobinson - 30 Jan 2009

Thanks Andrew for sharing the workaround. The proper solution is to fix the BatchUploadPlugin by sanitizing and untainting user supplied parameters before handing them over to Archive::Zip.

-- PeterThoeny - 01 Feb 2009

I've been searching high and low for a solution to the "Insecure dependency in chmod... line 393" error. This was informative (and humorous) http://twiki.csueastbay.edu/People/FixingBatchUpload. But, the conclusion was that BatchUploadPlugin needed to be rewritten frown

Andrew, your workaround didn't work for me. Any other tips? Is there another 'T' I should remove? I tried removing it from both bin/attach and bin/upload. But I still get the same error.

Any other workaround ideas?

-- AlexanderPico - 11 Feb 2009

Hi Alex

Sorry, I don't have any other solutions. Is it possible that your perl install is somehow defaulting to the 'T' option? I don't know enough about perl to know if that's possible or not but I agree with Peter's comments that it really should be fixed in the plugin smile

-- AndrewRobinson - 30 Mar 2009

It took some time to figure this out, but this works for our TWiki 5.1.1 instance:

Problem 1: TWiki is startes with Perl option -T for security reasons. This results in the error "Insecure dependency in chmod while running with -T switch" while uploading a ZIP file. The error itself occurs in CPAN Archive::Zip in file "Archive/Zip/Member.pm" at line "chmod ($self->unixFileAttributes(), $name)" when Archive::Zip tries to chmod the extracted file.

Solution for Problem 1: replace "chmod ($self->unixFileAttributes(), $name)" in file "Archive/Zip/Member.pm" with "chmod (0644, $name)"

Problem 2: BatchUploadPlugin may return the additional error: "Can't locate object method "redirect" via package "TWiki::Request"" or "Can't locate object method "redirect" via package "TWiki::Request""

Solution for Problem 2: replace "print $cgiQuery->redirect($url);" in "twiki/lib/TWiki/Plugins/BatchUploadPlugin.pm" with "print "Location: $url\n\n";"

-- JanoGebelein - 2012-06-21

Thanks a million, Jano -- those two steps solved the same problem for me too. Actually, for Problem 1 I used the patch to Archive::Zip proposed at https://rt.cpan.org/Public/Bug/Display.html?id=61930 -- too bad that doesn't seem to have been incorporated into Archive::Zip.

I wonder whether there is some "better" way to solve Problem 2 than manually outputting a "Location" header though? I tried TWiki::Func::redirectCgiQuery but got a "premature end of script headers."

-- MichaelShulman - 2012-07-12

@MichaelShulman, how do you apply the patch you mention for Problem 1?

-- Mark Stuart - 2014-01-30

Mark: See HowToApplyPatch and http://jungels.net/articles/diff-patch-ten-minutes.html

-- Peter Thoeny - 2014-01-30

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatpatch BatchUploadPlugin.patch r2 r1 manage 2.3 K 2005-09-23 - 14:25 SteveHobbs Patch as discussed by TobyCabot on 15 Feb 2005 and DiabJerius on 03 Dec 2004
Unknown file formatpatch BatchUploadPlugin_zip_option.patch r1 manage 1.6 K 2007-02-19 - 08:20 MartinRothbaum Patch to allow zip files to be preserved on upload
Compressed Zip archivezip MyBatchUpload.zip r1 manage 26.9 K 2007-01-17 - 13:03 SopanShewale Contains Store.pm, Upload.pm and couple of attachment templates-make sure to take the backup of lib and templates before extracting this zip filei
Unknown file formatJPG batchuploadattachmentscreen.JPG r1 manage 33.2 K 2007-01-12 - 13:47 SopanShewale  
Edit | Attach | Watch | Print version | History: r108 < r107 < r106 < r105 < r104 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r108 - 2014-01-30 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2016 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.