firebase storage : Error: storage/unknown No content provider

Viewed 468

I would like to put a simple jpg in the firebase storage. I can return a file ok but not to push a simple file. I use an android emulator for my test.

my function

const uri =  http://...:8081/assets/src/assets/images.jpg?platform=android&hash=131a57e2363da7e4dada04c4f2d34f85
 return new Promise((resolve, reject) => {
        storage()
            .ref('/images/test.jpg')
            .putFile(uri )
            .then((snapshot) => {
                console.log('test.jpg has been successfully uploaded.');
                resolve()
            })
            .catch((e) => {
                console.log('uploading image error => ', e)
                reject()
            });
    })

my error

Error: [storage/unknown] No content provider: http://....:8081/assets/src/assets/images.jpg?platform=android&hash=131a57e2363da7e4dada04c4f2d34f85

1 Answers

You can upload files to Cloud Storage from Firebase from three types of sources:

  1. From data that you have in memory as a byte array.
  2. From data that you have in memory as a string.
  3. From a file that you have on the local disk of your device.

What you are trying to do is upload data from a URL, which is not one of the supported options. If you want to store the image from that URL in Firebase, you will have to download the data from the URL to your local device, and then upload it from there.

Related