CulturalMe / meteor-slingshot

Upload files directly to AWS S3, Google Cloud Storage and others in meteor
MIT License
594 stars 105 forks source link

Issue when uploading multiple files asynchronously to S3 #190

Closed shantanubhadoria closed 8 years ago

shantanubhadoria commented 8 years ago
angular.forEach(files, function(file) {
  ctrl.uploader.send(file, function(error, downloadURL) {
    if (error)
      console.error('Error uploading', ctrl.uploader.xhr.response);
  });
});

When I upload multiple files, for some of the files(randomly) I get a EntityTooLarge error response in the upload attempt inspite of the individual files being small.

I get the following (400) error on my POST request to AWS. My maxSize is set to 5 MB and the total size of all my files combined is still way less than 5MB.

For some reason, in the failed upload responses the MaxSizeAllowed is always just slightly more than the ProposedSize.

<Error>
  <Code>EntityTooLarge</Code>
  <Message>Your proposed upload exceeds the maximum allowed size</Message>
  <ProposedSize>156623</ProposedSize>
  <MaxSizeAllowed>154874</MaxSizeAllowed>
  <RequestId>XXXXXX</RequestId>
  <HostId>XXXXXX</HostId>
</Error>

Another example of response:

<Error>
  <Code>EntityTooLarge</Code>
  <Message>Your proposed upload exceeds the maximum allowed size</Message>
  <ProposedSize>230335</ProposedSize>
  <MaxSizeAllowed>228908</MaxSizeAllowed>
  <RequestId>XXXXX</RequestId>
  <HostId>XXXXXXX</HostId>
</Error>
shantanubhadoria commented 8 years ago

I just realised you need to create unique upload objects for each file. My bad. Closing this ticket.