Parts of this page have been copied to HelpOnActions/AttachFile. In the next days, I will complete the move. -- AlexanderSchremmer 2005-10-15 22:39:05
I have altered the text to be more generic, sorry I should have done this with the example previously. Do you have planned already to make new example images by using the patch in 1.5? I could exchange the images with the patch in 1.3.5 too -- ReimarBauer 2005-10-16 06:34:24
- I just wanted to upload the existing ones. If you are not busy, you could redo them with an English locale and the 1.5 code base.
Finished -- ReimarBauer 2005-10-16 22:04:25
- I just wanted to upload the existing ones. If you are not busy, you could redo them with an English locale and the 1.5 code base.
The unzip feature
To get access to the unzip feature you need the following rights of the page:
- read
- write
- delete
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
no rights to unzip
If you have not enough rights you do only see the usual dialogue
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
This behaviour is controlled by the variable: attachments_file_space
successful unzipped
repeating unzip
If you try to unzip the file again then it is first checked if there is enough space available
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
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.
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
- probably an unpacking acl right for the pages where we like to use unzip
- probably meta information stored of each page for the amount of attachment file space already used.
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
Please could you attach here a small example zip file for me. Sorry for the type mismatches! -- ReimarBauer 2005-04-30 15:29:39
I've attached UploadDir.zip. -- GregWhittier 2025-04-22 11:49:19
- It contains a directory. And files in directories are ignored (see above).
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 2025-04-22 11:49:19 Please use @ SIG @ (without the blanks) to set your WikiName and DateTime
Someone told me the natural way would be to select files and to use the "Send To" Option with the right mouse click. And there were different tools on different windows versions to make zip files. But we got stuck here. Let's collect first how zip files could be created. If I understand you correctly you will give your user an advertise how to make the right way a zip file for upload to a wiki. So someone else may be have an idea which will fits your needs too. -- ReimarBauer 2005-05-01 13:43:47
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
- It normally does. Besides that, both ways are possible. Note that older Winzip releases did not you use a directory inside the ZIP file (and kept a flat hierachy normally).
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
It will be in 1.5b5/1.5rc1 (slightly modified). -- AlexanderSchremmer 2005-12-04 11:35:38
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
There is a var defined in your wikiconfig, see HelpOnConfiguration unzip_attachments_count -- ReimarBauer 2007-04-10 12:34:35