Multipart upload doesn't work on Android


#1

Hi all,

I have tried nativescript-background-http plugin (https://github.com/NativeScript/nativescript-background-http/tree/master/nativescript-background-http) with sample app from https://github.com/NativeScript/sample-ImageUpload and it works perfectly fine, but when I tried to change it to multipart upload I get this error on Android (iOS works fine).

In example I just changed this line:

var task = session.uploadFile(fileUri, request);

to this:

var params = [{name: "firstName", value: "Dave"}, {name:"file", filename: fileUri, mimeType: 'image/jpeg'}];
var task = session.multipartUpload(params, request);  

Error:

JS: ERROR Error: Uncaught (in promise): Error: java.lang.Exception: Failed resolving method addParameter on class net.gotev.uploadservice.MultipartUploadRequest
JS:     com.tns.Runtime.resolveMethodOverload(Runtime.java:982)
JS:     com.tns.Runtime.callJSMethodNative(Native Method)
JS:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1021)
JS:     com.tns.Runtime.callJSMethodImpl(Runtime.java:903)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:890)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:874)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:866)
JS:     com.tns.NativeScriptActivity.onActivityResult(NativeScriptActivity.java:69)
JS:     android.app.Activity.dispatchActivityResult(Activity.java:6192)
JS:     android.app.ActivityThread.deliverResults(ActivityThread.java:3570)
JS:     android.app.ActivityThread.handleSendResult(ActivityThread.java:3617)
JS:     android.app.ActivityThread.access$1300(ActivityThread.java:151)
JS:     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1352)
JS:     android.os.Handler.dispatchMessage(Handler.java:102)
JS:     android.os.Looper.loop(Looper.java:135)
JS:     android.app.ActivityThread.main(ActivityThread.java:5254)
JS:     java.lang.reflect.Method.invoke(Native Method)
JS:     java.lang.reflect.Method.invoke(Method.java:372)
JS:     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
JS:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
JS: Error: java.lang.Exception: Failed resolving method addParameter on class net.gotev.uploadservice.MultipartUploadRequest
JS:     com.tns.Runtime.resolveMethodOverload(Runtime.java:982)
JS:     com.tns.Runtime.callJSMethodNative(Native Method)
JS:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1021)
JS:     com.tns.Runtime.callJSMethodImpl(Runtime.java:903)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:890)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:874)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:866)
JS:     com.tns.NativeScriptActivity.onActivityResult(NativeScriptActivity.java:69)
JS:     android.app.Activity.dispatchActivityResult(Activity.java:6192)
JS:     android.app.ActivityThread.deliverResults(ActivityThread.java:3570)
JS:     android.app.ActivityThread.handleSendResult(ActivityThread.java:3617)
JS:     android.app.ActivityThread.access$1300(ActivityThread.java:151)
JS:     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1352)
JS:     android.os.Handler.dispatchMessage(Handler.java:102)
JS:     android.os.Looper.loop(Looper.java:135)
JS:     android.app.ActivityThread.main(ActivityThread.java:5254)
JS:     java.lang.reflect.Method.invoke(Native Method)
JS:     java.lang.reflect.Method.invoke(Method.java:372)
JS:     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
JS:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
JS:     at Function.Task.createMultiPart (file:///data/data/org.xxxxxx.xxxxxx/files/app/tns_modules/nativescript-background-http/background-http.js:132:25)
JS:     at Session.multipartUpload (file:///data/data/org.xxxxxx.xxxxxx/files/app/tns_modules/nativescript-background-http/background-http.js:70:21)
JS:     at sendImages (file:///data/data/org.xxxxxx.xxxxxx/files/app/pages/mainTabs/mainTabs.component.js:1385:36)
JS:     at file:///data/data/org.xxxxxx.xxxxxx/files/app/pages/mainTabs/mainTabs.component.js:1350:40
JS:     at ZoneDelegate.invoke (file:///data/data/org.xxxxxx.xxxxxx/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:365:26)
JS:     at Object.onInvoke (file:///data/data/org.xxxxxx.xxxxxx/files/app/tns_modules/@angular/core/bundles/core.umd.js:4156:37)
JS:     at ZoneDelegate.invoke (file:///data/data/org.xxxxxx.xxxxxx/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:364:32)
JS:     at Zone.run (file:///data/data/org.xxxxxx.xxxxxx/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:125:43)
JS:     at file:///data/data/org.xxxxxx.xxxxxx/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:760:57
JS:     at ZoneDelegate.invokeTask (file:///data/data/
JS: org.xxxxxx.xxxxxx/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:398:31)
JS:     at Object.onInvokeTask (file:///data/data/org.xxxxxx.xxxxxx/files/app/tns_modules/@angular/core/bundles/core.umd.js:4147:37)
JS:     at ZoneDelegate.invokeTask (file:///data/data/org.xxxxxx.xxxxxx/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:397:36)
JS:     at Zone.runTask (file:///data/data/org.xxxxxx.xxxxxx/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:165:47)
JS:     at drainMicroTaskQueue (file:///data/data/org.xxxxxx.xxxxxx/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:593:35)

Thank you