NativeScript / firebase

Modular Firebase 🔥 implementation for NativeScript. Supports both iOS & Android platforms for all Firebase services.
https://docs.nativescript.org/plugins/firebase-core.html
Apache License 2.0
52 stars 46 forks source link

[Firebase-storage][Android] Error: An unknown error occurred, please check the HTTP result code and inner exception for server response. #236

Open GM-VF opened 9 months ago

GM-VF commented 9 months ago

Error: An unknown error occurred, please check the HTTP result code and inner exception for server response.

const file = File.fromPath(files.files[0], true);

gives me

"_path": "/storage/emulated/0/Download/877981_QSG_SSB600-SOUNDBAR_ml.pdf", "_name": "877981_QSG_SSB600-SOUNDBAR_ml.pdf", "_extension": ".pdf"

Upload

firebase()
.storage()
.ref()
.child(remoteFullPath)  // Firebase url
.putFile(localFullPath) // /storage/emulated/0/Download/877981_QSG_SSB600-SOUNDBAR_ml.pdf
.on('state_changed', {
    complete() {
        console.info('uploadFile', 'completed');
    },
    error(err) {
        console.error('uploadFile', 'error', err);
    },
    next(snapshot) {
        console.info('uploadFile', 'next', 'state', snapshot.state);
        if (snapshot.totalBytes) {
            console.log('uploadFile', 'next', 'progress %', snapshot.bytesTransferred / snapshot.totalBytes ?? 0 * 100);
        }
        if (snapshot.error) {
            console.error('uploadFile', 'next', snapshot.error);
        }
    },
});

Any ideas?

GM-VF commented 9 months ago

One thing I should add is that the above is the nativescript ui-document-picker. Using the nativescript-image picker if I create an image and store it in my app's directory the above works fine with the following url.

/data/user/0/org.nativescript.app/files/app-name/filename.ext