Multipart upload doesn't work on Android
See original GitHub issueHi all,
I have tried this plugin 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)
Any help would be appreciated. thanks
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
android 9 file upload (MultipartUploadRequest) error
After this I started having issue connecting to server in (only) android 9. This turned out to be clearTextTraffic disabled issue as the...
Read more >Multipart Image Upload in Android 10+ to PHP Server - YouTube
So, who wants to become developer learn android. There are many methods to learn includes problem with solution, practical program, ...
Read more >Listing multipart uploads - Amazon Simple Storage Service
Listing multipart uploads ; 1. Create an instance of the ListMultipartUploadsRequest class and provide the bucket name. ; 2. Run the AmazonS3Client.
Read more >Uploading and copying objects using multipart upload
Multipart upload allows you to upload a single object as a set of parts. Each part is a contiguous portion of the object's...
Read more >Android: Upload image or file using http POST multi-part
I'm trying to upload image to my server using Android 1.5 SDK. By using this method, you will be able ... The problem...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
A note is added in the README to explicitly specify that the values sent to
multipartUpload
method should be strings.@bachras one more thing, I did get a similar error to the one you posted after experimenting more with this. My issue was that I had
let params = [{name: "person_id", value: this._peopleService.selectedPerson.person_id}, {name:"file", filename: dbname, mimeType: 'application/x-sqlite3'}];
where this._peopleService.selectedPerson.person_id was a number so I just did this and the error went awayvalue: this._peopleService.selectedPerson.person_id.toString()