react-native-background-upload icon indicating copy to clipboard operation
react-native-background-upload copied to clipboard

Cancelled event listener triggered immediately.

Open halaharr opened this issue 7 years ago • 7 comments

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

halaharr avatar Oct 11 '18 16:10 halaharr

Hi, you're probably having a server or connectivity issue I imagine

TSMMark avatar Oct 11 '18 18:10 TSMMark

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.

halaharr avatar Oct 11 '18 19:10 halaharr

We can't really help unless you can reproduce the issue using the example app https://github.com/Vydia/ReactNativeBackgroundUploadExample

TSMMark avatar Oct 11 '18 20:10 TSMMark

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

halaharr avatar Oct 12 '18 15:10 halaharr

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

halaharr avatar Oct 12 '18 16:10 halaharr

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 avatar Oct 15 '18 15:10 halaharr

@halaharr Did you figure this out? I'm having the same problem.

amie-wilt avatar Mar 07 '19 21:03 amie-wilt