Vydia / react-native-background-upload

Upload files in your React Native app even while it's backgrounded. Supports Android and iOS, including camera roll assets.
MIT License
723 stars 330 forks source link

Support for S3 multipart upload? #213

Open gyoung-panopto opened 4 years ago

gyoung-panopto commented 4 years ago

Hi there,

I'm wondering if this module supports uploading with the AWS S3 multipart upload protocol: https://docs.aws.amazon.com/AmazonS3/latest/dev/mpuoverview.html

I see that "multipart" upload is included in the documentation but I assume this means multipart/form-data encoding rather than the S3 multipart upload protocol.

Thanks for the information!

petrbela commented 3 years ago

Yeah multipart/form-data is used when you're POSTing a file along with other metadata. (btw this is one of the two options to do a regular S3 upload by POSTing to the bucket; the second option is a PUT to the key directly).


S3 multipart, or any other chunking protocol, works by splitting the file into multiple chunks which are uploaded separately. The steps are typically:

  1. Notify the backend that we're starting a multipart upload (CreateMultipartUpload)
  2. PUT each chunk
  3. Tell the backend all the parts have been uploaded (CompleteMultipartUpload)

You could probably manage this workflow (1 and 3) yourself in JS, along with splitting the file into chunks, and then send each chunk to background-upload which will take care of uploading it (2). Not sure if there's a ready-made solution for this, probably out of scope for this library.

jkerb8 commented 1 year ago

I'm looking to do the same thing with this library. The only issue i'm having is when it comes to splitting the binary file into chunks. Has anyone found out how to do this with react-native?