Upload Big
The experimental page Special:Upload Big is made to replace the Special:Update page. While the old page uses the standard HTML-PHP upload functions which are limited in interactivity and responsiveness, the new page uses an AJAX approach.
When you select a file and start the upload, the script upload.js takes care of the file.
- The client script treats the file in chunks of 1 MB size. For each chunk, it calculates an MD5 checksum and adds it to a job list.
- The client then checks on the server if a chunk is already present from an interrupted upload. If yes, it removes it from the job list. The system is resilient, if for any reason the user closed the window or the browser.
- The client uploads then each chunk individually to the server together with the checksum. 1 MB takes about 1 second or less, which allows for an interactive progress bar. For fun, we display also the checksum as bitmap.
- On the server side, the uploadbigfile.php script receives the chunk. It calculates its own MD5 checksum, and if it is the same, it saves it to site/uploadbig with the checksum as filename. Therefore, we are sure that each chunk is valid.
- Wen all chunks are uploaded, the client sends a composer list and the filename. The server then concatenates all chunks to the definitive file. If any file is missing, it advices the client who completes the upload. If the file is ok, it deletes the chunks, moves the file to site/files and creates an image page.
The server does also some housekeeping:
- Orphan chunks (eg chunks older than 24h) are deleted.
- The filename is cleaned to the url version of the filename.
- If the user proposes a filename with an extension that is not the same as the extension of the file, it adds the extension of the original file.
The upload big can also be used as function uploadzone to add in any page. This way you can give a customized upload access to your partners. You can control the upload
- putting it on a page with a a namespace and giving access control
- forcing the name (parameter 1)
- forcing a prefix
You can even create a listing of the uploaded files, when you use prefix.
filter _name "image:myprefix-", filesize, comment
rename _name name
update name = substr(name,6,99)
update name = _leftsquare._leftsquare."Media:".name._rightsquare._rightsquare
project name, filesize, comment
order name
print