Open halaharr opened 6 years ago
Hi, you're probably having a server or connectivity issue I imagine
It is not connectivity issue. I was able to get data from server. Not sure why the cancel event triggeres immediately. Any help would be appreciate it.
We can't really help unless you can reproduce the issue using the example app https://github.com/Vydia/ReactNativeBackgroundUploadExample
Hi, Is it cancelling immediately because I am trying to upload the data from documents directory. I have all the photos that the user took stored in a specific folder and I am trying to upload the photos from that folder.
ex: on simulator "file://Users/halaharvi/Library/Developer/CoreSimulator/Devices/D6302B46-E57D-40A9-94AC-D232695EF081/data/Containers/Data/Application/06FE2D05-1B27-467A-BE2E-757773238EBE/Documents/pictures/123456/9004749/9004749_Street Sign_20181012_113855.522.jpg"
Thanks
Triggering of cancelling event went away after removing spaces from path but I am getting new error. Error: NSInvalidArgumentException at createErrorFromErrorData (NativeModules.js:121) at NativeModules.js:78 at MessageQueue.invokeCallback (MessageQueue.js:398) at MessageQueue.js:137 at MessageQueue.guardSafe (MessageQueue.js:314) at MessageQueue.invokeCallbackAndReturnFlushedQueue (MessageQueue.js:136) at t (RNDebuggerWorker.js:1)
Please let me know if I am passing anything else wrong.
Thanks
Hi
I am still having this issue. Not sure what argument I am passing wrong. Here is the options I am passing:
getFileInfo(path)
.then(res => {
options = Object.assign({
url: ${config.ApiUrl}PhotoUpload/PostSinglePhoto/${inum}
,
type: 'raw',
method: 'POST',
path,
headers: {
'content-type': res.mimeType
}
});
console.log('---options---->', options);
startUpload(options)
but once startUpload is called I get the following error: Error: NSInvalidArgumentException at createErrorFromErrorData (NativeModules.js:121) at NativeModules.js:78 at MessageQueue.invokeCallback (MessageQueue.js:398) at MessageQueue.js:137 at MessageQueue.guardSafe (MessageQueue.js:314) at MessageQueue.invokeCallbackAndReturnFlushedQueue (MessageQueue.js:136) at t (RNDebuggerWorker.js:1)
Thanks
@halaharr Did you figure this out? I'm having the same problem.
Hi, I am trying to use this plugin and cancelled event listener is triggered immediately after start. Here s my code
const options = { url:
${config.ApiUrl}PhotoUpload/PostSinglePhoto/${inum}
, path, method: 'POST', headers: { 'Content-Type': 'application/octet-stream', authorization:Bearer ${jwt}
, 'File-Name': path.slice(path.lastIndexOf('/') + 1), 'File-Size': photo.size } };console.log('-------before submitting photo-----', options); startUpload(options) .then(uploadId => { console.log('Upload started'); addListener('progress', uploadId, data => { console.log(
Updload photo ---- Progress: ${data.progress}%
); }); addListener('error', uploadId, data => { console.log(Updload photo ---- Error: ${data.error}%
); }); addListener('cancelled', uploadId, data => { console.log('Updload photo ---- Cancelled!', data); }); addListener('completed', uploadId, data => { // data includes responseCode: number and responseBody: Object console.log('Updload photo ---- Completed!'); }); }) .catch(err => { console.log('Updload photo ---- Upload error!', err); });Not sure why the cancel event trigger. Thanks