Difference between revisions of "Limiting Upload File Size"
(Added howto for limiting file upload) |
(escapes HTML markup for phrase.) |
||
Line 20: | Line 20: | ||
After these changes you will now need to add a phrase to warn the user when the file is to large. You can add this to either an existing or by creating you own new phrases file in your archive's ''cfg/lang/en/phrases/'' directory. | After these changes you will now need to add a phrase to warn the user when the file is to large. You can add this to either an existing or by creating you own new phrases file in your archive's ''cfg/lang/en/phrases/'' directory. | ||
− | + | <epp:phrase id="Plugin/Screen/EPrint/UploadMethod/File:filesize_too_big">The file size exceeds the limit allowed and cannot be uploaded.</epp:phrase> | |
[[Category:Howto]] | [[Category:Howto]] |
Revision as of 16:38, 20 January 2023
There are various things that may affect the maximum size of file you can upload to EPrints. One of the most common is Apache's LimitRequestBody which by default limits the maximum file upload to 1 GiB. However, when uploading a file larger than 1 GiB with EPrints file uploader (i.e. on the Upload stage of the eprint workflow) rather than telling you this is not possible, it just sits there any never uploads the file.
For both the reason above and that more generally you may want to stop users from uploading excessively large files, you may want to restrict the maximum file size that the EPrints file uploader will permit for upload and warn users if files are too large to upload rather than leaving them wondering what went wrong. This can be done by copy 88_uploadmethod_file.js to you archive's cfg/static/javascript/auto/ (creating such a directory if it does not already exist) and editing it as follows:
1. At the start of the file add the line, which sets max_size to 1 GiB (you can set this higher or lower if you want):
max_size = 1*1024*1024*1024; //max file size allowed in bytes.
2. Around the two occurences of this.createFile (files[i]);
at an if statement to change it to the following:
if (this.checkFilesize(files[i])) { this.createFile (files[i]); }
3. After the line add the following if block:
if (json.size > max_size) { UploadMethod_cancel(uuid); eprints.currentRepository().phrase( {'Plugin/Screen/EPrint/UploadMethod/File:filesize_too_big':{} },function(phrase){ alert (phrase["Plugin/Screen/EPrint/UploadMethod/File }
After these changes you will now need to add a phrase to warn the user when the file is to large. You can add this to either an existing or by creating you own new phrases file in your archive's cfg/lang/en/phrases/ directory.
<epp:phrase id="Plugin/Screen/EPrint/UploadMethod/File:filesize_too_big">The file size exceeds the limit allowed and cannot be uploaded.</epp:phrase>