NativeScript / nativescript-background-http

Background Upload plugin for the NativeScript framework
Apache License 2.0
101 stars 50 forks source link

[feat](ios) Add ios assets-library url support #259

Open NathanaelA opened 4 years ago

NathanaelA commented 4 years ago

PR Checklist

What is the current behavior?

On iOS all assets-library urls are unable to be uploaded; normally you will get an assets-library url from a Gallery picker.

What is the new behavior?

  1. assets-library:// urls are detected and are able to be uploaded.
    • PHAsset based urls should be able to now be easily added to the code base, as the assets-library urls are converted to the modern PHAsset.
  2. demo-server now handles multipart properly so we can verify everything is correctly built and uploaded.
  3. Multipart uploads now handle multiple large files without running out of memory as all changes are now streamed to disk directly rather than to a large memory pointer (which was then written)...

Fixes/Implements/Closes #[Issue Number]. N/A

BREAKING CHANGES: uploadFile / multipartUpload now return a PROMISE instead of a task. The Promise will resolve with the task. However, the process to ask iOS for permission to access the gallery item and retrieve the item from the PHAsset system requires callbacks; requiring that these now return a promise that retrieves the task so that the task can still be created properly...

Migration steps: Change

let task = uploadFile(...)
// All your older code

to

let promiseTask = uploadFile(...);
promiseTask.then( (task) => {
   // All your older code
});

or

let task = await uploadFile(...);
// All your older code