Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Amplify Storage | Upload large file

Using AWS Amplify Storage, uploading a file to AWS S3 should be simple:

Storage.put(key, blob, options)

The above works without problem for smaller files, (no larger than around 4MB).

Uploading anything larger, ex. a 25MB video, does not work: Storage just freezes (app does not freeze, only Storage). No error is returned.

Question: How can I upload larger files using AWS Amplify Storage?

Side note: Described behaviour appears both on Android and iOS.

like image 984
Vingtoft Avatar asked Oct 22 '25 16:10

Vingtoft


2 Answers

Amplify now automatically segments large files into 5Mb chunks and uploads them using the Amazon S3 Multipart upload process

https://aws.amazon.com/about-aws/whats-new/2021/10/aws-amplify-javascript-file-uploads-storage/

https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html#mpu-process

like image 52
Sam - OnePunchManTwo Avatar answered Oct 25 '25 07:10

Sam - OnePunchManTwo


After updating to

"aws-amplify": "ˆ4.3.11",
"aws-amplify-react-native": "^6.0.2"

uploads over 100MB are not freezing UI anymore + we also migrated to resumable uploads. When we used older version of aws-amplify": "^3.1.1", the problems like you mentioned were present.

Here is the pull request from Dec, 2021 for mentioned fixes: https://github.com/aws-amplify/amplify-js/pull/8336

So the solution is really to upgrade AWS Amplify library.

However, this approach works only on iOS. Uploading big media files on Android results in network error when calling fetch (as a required step before calling Storage.put method).

Although the same method can perfectly work on the web, in React Native uploading big files was/is not implemented optimally (taking in mind, that we should load all file in memory using fetch()).

like image 20
Stefan Majiros Avatar answered Oct 25 '25 06:10

Stefan Majiros