NativeScript / nativescript-background-http

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

Error during upload #100

Closed radhe12 closed 6 years ago

radhe12 commented 6 years ago

I am running app on android file Upload of android give's me error - "Error during upload" here is my code. `camera.takePicture({ width: 200, height: 200, keepAspectRatio: true, saveToGallery: true })
.then(function (imageAsset) { console.log("Result is an image asset instance"); console.log("Image taken!"); filepath = fs.path.join(android.os.Environment.getExternalStoragePublicDirectory(android.os.Environment.DIRECTORY_DCIM).getAbsolutePath(), "Test" + ".jpg");

    imageAsset.getImageAsync(image => {

    imagecontainer.imageSource = imageSource.fromNativeSource(image);
   (imagecontainer.imageSource).saveToFile(filepath, uiEnums.ImageFormat.jpeg);

    });
    var request = {
        url: "http://10.10.10.105/DockToStockAPI/Sample/PostUserImage",
        method: "POST",
        headers: {
            "Content-Type": "multipart/form-data",
            "File-Name": "Test.jpg"
        },
        description: "{ 'uploading': " + "Test.jpg" + " }"
    };

    var task = session.uploadFile(filepath, request)
    task.on("progress", logEvent);
    task.on("error", logEvent);
    task.on("complete", logEvent);

    function logEvent(e) {
        console.log("----------------");
        console.log('Status: ' + e.eventName);
        // console.log(e.object);
        if (e.totalBytes !== undefined) {
            console.log('current bytes transfered: ' + e.currentBytes);
            console.log('Total bytes to transfer: ' + e.totalBytes);
        }
    }

}).catch(function (err) {
    console.log("Error -> " + err.message);
});`

--------------Output------------------ JS: Status: progress JS: current bytes transfered: 4096 JS: Total bytes to transfer: 129388 JS: ---------------- JS: Status: progress JS: current bytes transfered: 129388 JS: Total bytes to transfer: 129388 JS: ---------------- JS: Status: complete

NickIliev commented 6 years ago

@radhe12 based on the info above the last line prints

S: Status: complete

Can you post the error log?

tsonevn commented 6 years ago

closing due to inactivity

radhe12 commented 6 years ago

@tsonevn @NickIliev here is my question with web api please let me know if I am doing anything wrong - https://stackoverflow.com/questions/48708574/error-during-upload-in-nativescript