NativeScript / nativescript-background-http

Background Upload plugin for the NativeScript framework
Apache License 2.0
102 stars 50 forks source link

Android: Multipart Upload Throwing Uncaught Exception #127

Closed lin-brian-l closed 6 years ago

lin-brian-l commented 6 years ago

We are attempting to use session.multipartUpload() to upload to our server, and the same code works fine for iOS but fails on Android. The error that appears is extremely similar to the error in this thread, and after looking through other issues such as #124, I'm inclined to think that the error lies with an incompatibility with SDK 26 rather than the session code itself. For reference, the session call is as follows:

        var session = bghttp.session("image-upload");
        var request = {
            url: Config.apiUrl,
            method: "POST",
            headers: {
                "Content-Type":"application/octet-stream",
                "File-Name": reqID + ".png"
            },
            description: "uploading image",
            // androidDisplayNotificationProgress: false // this didn't work
        };

        let params = [
            {name: "id", value: reqID},
            {name:"image", filename: path, mimeType: 'image/png'}
        ];
        var task = session.multipartUpload(params, request);

Is there anything that can be done to have the issue resolved? I tried following the advice given in the first issue that I linked, but we are already compiling to SDK version 26 in our app/App_Resources/Android/app.gradle file (compileSdkVersion 26 and buildToolsVersion '26.0.2'). Are there any other solutions that we can attempt to get this resolved?

tsonevn commented 6 years ago

Hi @lin-brian-l, Make sure that you are using latest available nativescript-background-http version(3.2.2). If you are already using it, try to remove the platform and to add it again. tns platform remove android tns platform add android

If the issue persists, please send us sample project, which could be used for debugging.