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
730 stars 333 forks source link

Add capability to upload multiple files and array of string parameters in one request #304

Open ydhnwb opened 2 years ago

ydhnwb commented 2 years ago

Summary

Add capability to upload multiple files in one request and array of string in parameters.

Test Plan

Android only, multiple files upload in one shot via Multipart

Send all the files in files param. In this case path, field & type will be ignored. Example:

const options = {
  url: 'https://myservice.com/path/to/post',
  files: [
    {
      path: 'file://path/to/file%20on%20device.png',
      field: 'uploaded_media'
    }
  ],
  method: 'POST'
}

Note that type will always be multipart when files is passed

Android only, multiple parameters in one shot via Multipart

Send parameters as list of string.

const options = {
  url: 'https://myservice.com/path/to/post',
  files: [
    {
      path: 'file://path/to/file%20on%20device.png',
      field: 'uploaded_media'
    }
  ],
  paramaters: {
    urls: ["https://example.com", "http://example.com"]
  }
  method: 'POST'
}

However, if you pass the array with single value array like ["example.com"], it will be count as string in your backend. It is using request.addArrayParameter("key", List) in native code.

What's required for testing (prerequisites)?

What are the steps to reproduce (after prerequisites)?

Compatibility

OS Implemented
iOS
Android

Checklist