The unzip feature

To get access to the unzip feature you need the following rights of the page:

e.g.

#acl ReimarBauer:admin,read,write,delete All:read

There is some protection for the server implemented. zip files in a zip file are dropped by unzipping them. By defining of the var attachments_file_space only this total amount of bytes could be used to unzip files. If there are already files in the directory the amount of them are subtracted from this number. While an extracted file could be very large there is an other var defined to protect the system for unzipping to large files. This is done by the var single_file_size. My settings are:

attachments_file_space

200MB

single_file_size

2MB

For some of the examples I have changed attachments_file_space to 100MB.

The rules for unzipping are implemented in the same way as for uploading one file. It is not allowed to overwrite an existing file by unzipping a file.

By unzipping a zip file only files from the first layer are unzipped. files in directories are ignored.

A valid zip file could be created this way:

zip bremen.zip *.JPG

You should note for protection of the server it is the best to use only one level zip files and not a directory structure to unpack. For details about this see the description above at FeatureRequests/UploadMultipleAttachmentFiles. We should collect some information how this could be done easily by the different platforms. The example here shows how it could be used by unix systems.

I have tested this routine myself with linux using the DesktopEdition, a local wiki installation and on an apache2 webserver (cgi-bin) running on linux. -- ReimarBauer 2005-04-08 08:32:27

Upload a zip file

If you have uploaded a zip file you got the new unzip key shown
unzip1.png

no rights to unzip

If you have not enough rights you do only see the usual dialogue
unzip7.png

URL for unzipping

http://localhost:8080/RulesForUnzip?action=AttachFile&do=unzip&target=bremen.zip

not enough space free

If the resulting unpacked files do exceed the limit of filespace for attachments you got this warning
unzip2.png
This behaviour is controlled by the variable: attachments_file_space

successful unzipped

unzip3a.png
unzip3b.png

repeating unzip

If you try to unzip the file again then it is first checked if there is enough space available
unzip4.png
If it could be unzipped then existing files won't be overwritten

extracted file to large

If a file in the ziparchive exceeds by unzipping the defined single_file_size then it is not unzipped
unzip5.png
The example was created by

dd if=/dev/zero bs=1k count=10000 | zip test.zip -

zip files in zip file are dropped

If zip files are included in the zip archive then they are dropped. unzip6.png
So the famous 42.zip does not affect the system.

direct call of URL

If you don't have enough rights on the page you are not able to unzip a file by calling it with the URL.

http://localhost:8080/RulesForUnzip?action=AttachFile&do=unzip&target=bremen.zip

If wrong permissions are set, then you get the following meassage

You are not allowed to unzip attachments of this page.

code change

See PackageInstaller for an enhanced patch (fixed XSS issues, added view (i.e. list) ZIP file capability and finally added package handling)

1.3.4

I have used the AttachFile of Alexanders DesktopEdition 1.3.4-1.

1.3.5

Based on the version 1.3.4 AttachFile and the modification of the previous Zip-AttachfilePatch by AlexanderSchremmer here it is for the actual version. -- ReimarBauer 2005-08-05 11:38:08

what more could be done

Please show your results and (hopefully no) problems

I tried what I thought would be most natural to my users who use windows and have winzip installed. I created "upload_dir" and put the files in. Then I right-clicked on the directory and chose "Add to upload_dir.zip." After I upload this and click "unzip" I get : "Attachment 'upload_dir.zip' not unziped because result to big or included zip file or file exists."

The error message is confusing since I assume the unzip failed because unzip_file doesn't expect directories in the zip file. I can make detailed directions for creating zip files with all of the files at the top level, but it's more complicated in winzip that zipping a directory. (Also there are some misspellings in the message. "unziped" should be "unzipped" and "to" should "too." I'd suggest a rewording, but I'm not sure what the message is trying to say with "included zip file... exists.") -- GregWhittier

I've attached UploadDir.zip. -- GregWhittier 2024-05-09 22:38:58

I understand it contains a directory and that's why it was ignored. What I'm trying to say is that the most logical way to create a zip file on windows with winzip doesn't work for uploading a large number of files to MoinMoin. If you tell a windows user to upload a zip file of attachments, he will put them in a directory such as UploadDir and then right-click the directory and select Add to UploadDir.zip. With windows/winzip, creating a zip file without a directory is less natural. -- GregWhittier 2024-05-09 22:38:58 Please use @ SIG @ (without the blanks) to set your WikiName and DateTime

I'm placing instructions on creating zip files in a /ZipFileCreation subpage. WinZip doesn't have a "Send To" option. -- GregWhittier 2005-05-01 16:31:49

I have uploaded a patch that implements an exception for the above case of a single, common subdirectory within the zip file. I tested it with a few different zip files of different layouts and it seems to work as I would expect. AttachFile-1.3.5.unzipwithsubdir.patch --DiegoOngaro at ETSZONE 2005-11-23 21:39:41

And a patch for 1.5. Also changed a bit of the code for style. AttachFile-1.5.zipsubdir.patch --DiegoOngaro at ETSZONE 2005-11-23 22:33:50

I have a page with many attachments. I normally upload them in zip files an unzip these files, but now i get an error message like this when trying to unzip: Attachment 'DSCN1930.JPG.zip' could not be unzipped because the resulting files would be too many (118 missing) This happens with every zip archive i tried. Wikiversion 1.5.7

MoinMoin: FeatureRequests/UploadMultipleAttachmentFiles/RulesForUnzip (last edited 2009-07-11 00:25:24 by TakeoKatsuki)