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
735 stars 335 forks source link

Queuing of requests #160

Open dcurletti opened 5 years ago

dcurletti commented 5 years ago

Hi there- curious if this library has a queuing system in place to limit the number of simultaneous api calls?

ie. If you invoke Upload.startUpload(options).then() X number of times, what would occur?

TSMMark commented 5 years ago

I believe they will upload in parallel, but it's worth testing. A queueing system sounds like something people would like so I'll keep this open with help wanted

dcurletti commented 5 years ago

@TSMMark ios and android only allow for a certain number of concurrent requests to be made, is that correct?

From this documentation, it seems to be implying 6 for ios: https://developer.apple.com/documentation/foundation/nsurlsessionconfiguration/1407597-httpmaximumconnectionsperhost?language=objc

dcurletti commented 5 years ago

i believe on android the requests are being queued by the package android-upload-service.

andrejunqueira1 commented 4 years ago

i am using react-native-queue to control the flow of upload images.

deevus commented 2 years ago

This might seem like a naive approach, but maybe it will work.

Could you wrap the Upload functionality in a Promise so that the completed event resolves the promise?

Then use something like https://github.com/sindresorhus/p-map with concurrency: 1 to provide the concurrency limit?

I'm not sure how that would play with the background sessions.