Skip to content

Does not work with Android 8.0.0? #124

Closed
@fthuin

Description

@fthuin

Hello,

I have a Sony Xperia X with Android 8.0.0 and I just get an error with I call the function uploadFile(). The code works fine on Samsung S6 Android 7.0 and on iOS.

Note that no request ever arrives to the server so it's not a network error. It does not work on http nor https server.

Here is the portion of code if it helps

import * as bghttpModule from 'nativescript-background-http';


    constructor(
        ...
    ) {
        ...
        this.session = bghttpModule.session('image-upload-bg-http');
    }


    private sendImages(fileUri): Q.Promise<any> {
        const defer = Q.defer();

        const imageName = this.extractImageName(fileUri);

        const request = {
            url: ... [[ some rest api url ]],
            method: 'PATCH',
            headers: {
                'Content-Type': 'application/octet-stream',
                'File-Name': imageName,
                'Content-Disposition': `attachment; filename=${imageName}`,
                Authorization: ... [[anonymized]],
            },
            description: "{ 'uploading': " + imageName + ' }',
        };

        const task = this.session.uploadFile(fileUri, request);

        task.on('progress', logEvent);
        task.on('error', err => {
            defer.reject(err);
        });
        task.on('complete', () => {
            defer.resolve();
        });

        function logEvent(e) {
            console.log('currentBytes: ' + e.currentBytes);
            console.log('totalBytes: ' + e.totalBytes);
            console.log('eventName: ' + e.eventName);
        }

        return defer.promise;
    }

Here is the error log I have.

JS: === dump(): dumping members ===
JS: {
JS:     "eventName": "error",
JS:     "object": {
JS:         "_observers": {
JS:             "progress": [
JS:                 {
JS:                     "callback": "callback()function logEvent(e) {\n            console.log('currentBytes: ' + e.currentBytes);\n            console.log('totalBytes: ' + e.totalBytes);\n            console.log('eventName: ' + e.eventName);\n        }"
JS:                 }
JS:             ],
JS:             "error": [
JS:                 {
JS:                     "callback": "callback()function (err) {\n            defer.reject(err);\n        }"
JS:                 }
JS:             ],
JS:             "complete": [
JS:                 {
JS:                     "callback": "callback()function () {\n            defer.resolve();\n        }"
JS:                 }
JS:             ]
JS:         },
JS:         "_session": {
JS:             "_id": "image-upload-bg-http"
JS:         },
JS:         "_id": "image-upload-bg-http{1}",
JS:         "_description": "{ 'uploading': random-avatar-2.png }",
JS:         "_upload": 0,
JS:         "_totalUpload": 1,
JS:         "_status": "error"
JS:     },
JS:     "error": null
JS: }
JS: === dump(): dumping function and properties names ===
JS: === dump(): finished ===

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions