s3_direct_upload icon indicating copy to clipboard operation
s3_direct_upload copied to clipboard

Strange behaviour when file is too big

Open michaelbaudino opened this issue 11 years ago • 2 comments

Hi,

When setting max_file_size (e.g. 1.megabytes) in s3_uploader_form arguments, and trying to upload a file bigger than what's allowed (e.g. a 3 megabytes file), the s3_upload_failed event is correctly fired (as stated in the doc) but the progress bar does not disappear. Is this an expected behaviour ? And we have no way to find this progressbar (in order to hide it manually) since the fired event target is the whole form.

Furthermore, in that case, the XHR answer contains some XML, e.g.:

<?xml version="1.0" encoding="UTF-8"?>
<Error>
    <Code>EntityTooLarge</Code>
    <Message>Your proposed upload exceeds the maximum allowed size</Message>
    <ProposedSize>1050232</ProposedSize>
    <RequestId>3791A0CE2BF31BD4</RequestId>
    <HostId>ccoJ4iJMGSYVYqSP85L+nXACyQCUaZxg5y0h+tpJ72699sm8V/blaMyQeMgHKICV</HostId>
    <MaxSizeAllowed>1048576</MaxSizeAllowed>
</Error>

... but the only information we have access to from the event handler is the Bad Request string in the error_thrown field of the content object (is it from the HTTP response code ?). It would be great to have access to more specific error message as specified in the answer's XML.

Thanks in advance.

PS: if you want 2 separate issues, please let me know, I'll be glad to split it up.

michaelbaudino avatar Jul 24 '14 16:07 michaelbaudino

Workaround is to fileuploadfail instead of s3_upload_failed

$('form#fileupload').bind('fileuploadfail', function(e, data) { setTimeout(function() { alert($(data.jqXHR.responseXML).find("Message").text()) }, 0);

Hampei avatar Oct 29 '14 23:10 Hampei

+1 for passing the response object with the callbacks.

david-a avatar Dec 02 '15 18:12 david-a