Storage.put of multipart file returns successfully upon failure
See original GitHub issueBefore opening, please confirm:
- I have searched for duplicate or closed issues and discussions.
- I have read the guide for submitting bug reports.
- I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
JavaScript Framework
Not applicable
Amplify APIs
Storage
Amplify Categories
Not applicable
Environment information
aws-amplify: ^4.2.4 => 4.2.4
Describe the bug
When Storage.put fails at the end of a multipart upload (CompleteMultipartUpload), the call returns successfully and no error is thrown.
Expected behavior
An error should be thrown or returned to the caller, indicating that the upload failed.
Reproduction steps
- Misconfigure your S3 bucket so that it will fail at the end of a multipart upload. For instance, as long as the CORS settings are not exposing the ETag header, files larger than 5MB will fail to upload. See https://github.com/aws-amplify/amplify-js/issues/61#issuecomment-445436658
- Invoke Storage.put with a file that will cause the multipart upload to fail at the end. For instance, upload a file larger than 5MB to a bucket misconfigured as in step 1.
- OBSERVATION: an error is correctly logged: “AWSS3ProviderManagedUpload - error happened while finishing the upload. Cancelling the multipart upload Error: Request failed with status code 400” However, the call returns successfully, and no error is thrown.
Code Snippet
const object = await Storage.put(uploadPath, file, {
level: 'private',
contentType: file.type
})
console.log('object: ' + JSON.stringify(object))
Log output
18:36.583 axios-http-handler - Request failed with status code 400
18:36.584 AWSS3ProviderManagedUpload - error happened while finishing the upload. Cancelling the multipart upload Error: Request failed with status code 400
| push../node_modules/@aws-amplify/core/lib-esm/Logger/ConsoleLogger.js.ConsoleLogger._log | @ | ConsoleLogger.js:139
-- | -- | -- | --
| push../node_modules/@aws-amplify/core/lib-esm/Logger/ConsoleLogger.js.ConsoleLogger.error | @ | ConsoleLogger.js:210
| (anonymous) | @ | AWSS3ProviderManagedUpload.js:274
| step | @ | AWSS3ProviderManagedUpload.js:55
| (anonymous) | @ | AWSS3ProviderManagedUpload.js:36
| rejected | @ | AWSS3ProviderManagedUpload.js:28
| Promise.then (async) | |
| step | @ | AWSS3ProviderManagedUpload.js:29
| fulfilled | @ | AWSS3ProviderManagedUpload.js:27
| Promise.then (async) | |
| step | @ | AWSS3ProviderManagedUpload.js:29
| (anonymous) | @ | AWSS3ProviderManagedUpload.js:30
| push../node_modules/@aws-amplify/storage/lib-esm/providers/AWSS3ProviderManagedUpload.js.__awaiter | @ | AWSS3ProviderManagedUpload.js:26
| push../node_modules/@aws-amplify/storage/lib-esm/providers/AWSS3ProviderManagedUpload.js.AWSS3ProviderManagedUpload.finishMultiPartUpload | @ | AWSS3ProviderManagedUpload.js:250
| (anonymous) | @ | AWSS3ProviderManagedUpload.js:146
| step | @ | AWSS3ProviderManagedUpload.js:55
| (anonymous) | @ | AWSS3ProviderManagedUpload.js:36
| fulfilled | @ | AWSS3ProviderManagedUpload.js:27
| Promise.then (async) | |
| step | @ | AWSS3ProviderManagedUpload.js:29
| fulfilled | @ | AWSS3ProviderManagedUpload.js:27
| Promise.then (async) | |
| step | @ | AWSS3ProviderManagedUpload.js:29
| fulfilled | @ | AWSS3ProviderManagedUpload.js:27
| Promise.then (async) | |
| step | @ | AWSS3ProviderManagedUpload.js:29
| fulfilled | @ | AWSS3ProviderManagedUpload.js:27
| Promise.then (async) | |
| step | @ | AWSS3ProviderManagedUpload.js:29
| fulfilled | @ | AWSS3ProviderManagedUpload.js:27
| Promise.then (async) | |
| step | @ | AWSS3ProviderManagedUpload.js:29
| (anonymous) | @ | AWSS3ProviderManagedUpload.js:30
| push../node_modules/@aws-amplify/storage/lib-esm/providers/AWSS3ProviderManagedUpload.js.__awaiter | @ | AWSS3ProviderManagedUpload.js:26
| push../node_modules/@aws-amplify/storage/lib-esm/providers/AWSS3ProviderManagedUpload.js.AWSS3ProviderManagedUpload.upload | @ | AWSS3ProviderManagedUpload.js:87
| (anonymous) | @ | AWSS3Provider.js:401
| step | @ | AWSS3Provider.js:43
| (anonymous) | @ | AWSS3Provider.js:24
| fulfilled | @ | AWSS3Provider.js:15
| Promise.then (async) | |
| step | @ | AWSS3Provider.js:17
| (anonymous) | @ | AWSS3Provider.js:18
| push../node_modules/@aws-amplify/storage/lib-esm/providers/AWSS3Provider.js.__awaiter | @ | AWSS3Provider.js:14
| push../node_modules/@aws-amplify/storage/lib-esm/providers/AWSS3Provider.js.AWSS3Provider.put | @ | AWSS3Provider.js:326
| push../node_modules/@aws-amplify/storage/lib-esm/Storage.js.Storage.put | @ | Storage.js:270
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
[feature request] s3 multipart resumable uploads #61 - GitHub
So, I am asking it again. Is it available for the React Native projects? The biggest issue with a Storage.put in React Native...
Read more >Spring Boot multipartfile always null - java - Stack Overflow
I am trying to use multipart file upload but the MultipartFile is always null in the controller. When I use @RequestPart("file") the info:...
Read more >Uploading and copying objects using multipart upload
If any part uploads were in-progress, they can still succeed or fail even after you stop the upload. To make sure you free...
Read more >Spring Boot File upload example with Multipart File - BezKoder
In this tutorial, I will show you how to upload and download files with a Spring Boot Rest APIs to/from a static folder....
Read more >Spring Boot File Upload / Download Rest API Example
The FileController class uses FileStorageService for storing files in the file system and retrieving them. It returns a payload of type ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Any updates? This seems very important and could be raised in priority, as it’s the storage service, upload functionality, the bread and butter of AWS… Literally can’t tell apart a failed upload from a successful one. The workarounds bloat the build size considerably or require 1+ days of engineering time.
Closing as a duplicate of https://github.com/aws-amplify/amplify-js/issues/9703