nativescript-background-http
nativescript-background-http copied to clipboard
[feat](ios) Add ios assets-library url support
PR Checklist
- [X] The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/CONTRIBUTING.md#commit-messages.
- [ ] There is an issue for the bug/feature this PR is for. To avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it.
- [X] All existing tests are passing
- [ ] Tests for the changes are included
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?
-
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-libraryurls are converted to the modern PHAsset.
- demo-server now handles multipart properly so we can verify everything is correctly built and uploaded.
- 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