amplify-js: Storage.put fail with large files on Android with react-native
Storage.put need a blob to upload file.
But react-native has a fetch bug on android with “big” files. You can see here
When you try to uplaod video with size of 160mb or more, const response = await fetch(videoUri) get next error: TypeError: Network request failed(It isnt network error, with small sizes it work).
I have tried to generate the blob with https://github.com/joltup/rn-fetch-blob but I have not been able to make it works.
Is there a way to get it working or an alternative way to upload large files?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 5
- Comments: 17 (4 by maintainers)
Update: I have a working implementation locally now that doesn’t give the OOM error and should solve the UI freezing problem, its also significantly faster than before. Once I have properly tested it I will submit a PR.
Hey folks, I started doing some research on this issue and here’s what I found.
The issue likely stems from here: https://github.com/aws-amplify/amplify-js/blob/main/packages/storage/src/providers/AWSS3ProviderManagedUpload.ts#L316 As a work around for using Axios on React Native (They don’t support React native blobs). We implemented a change where we will transform the blob into an arrray bufer first. When the file is large enough it will hog all the memory which causes an OOM exception.
On top of that, during the transformation it freezes the UI.
Currently working on a fix, will give more updates soon.
@luisfuertes are you still looking for support on this issue? If so, please provide us information on your environment by running the following command:
npx envinfo --system --binaries --browsers --npmPackages --npmGlobalPackages. Also, if you can provide us a code snippet this will help us further assist you. Thanks ahead of time.