firebase-admin-node: Images uploaded through Firebase Admin SDK not displaying properly in the Firebase Console

[REQUIRED] Step 2: Describe your environment

Mac OS 10.14.6 firebase-admin : 8.7.0 Firebase Admin SDK Firebase Storage Node v10.16.0 Npm 6.12.0

[REQUIRED] Step 3: Describe the problem

I am uploading images to Firebase Storage from a Node.js app that I have built. The upload seems to go fine, but any image upload through the Firebase Admin SDK will not open in the Firebase Console. If I try clicking on the image I get:

`404. That’s an error.

The requested URL was not found on this server. That’s all we know.`

In the Firebase console detail inspector, it just infinitely spins showing a loading progress bar.

If I inspect the image through Google Cloud Console, the image opens fine.

I have not tested downloading the image from an app or through the Firebase Admin SDK to see if it works.

Steps to reproduce:

Upload an image using the Node JS Firebase Admin SDK. I have tried this to multiple directories and I get the same issue every time.

Relevant Code:

await FirebaseAdmin.storage().bucket().upload(`./ImageName/${ImageName}.png`, {destination: `Image/${ImageName}/${ImageName}.png`, gzip: true, contentType: "image/png", metadata: {contentType: "image/png"}})

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 24 (5 by maintainers)

Most upvoted comments

Hi, I was have same error, review google cloud console if very simple, no display in console because firebase console need firebaseStorageDownloadTokens, check example:

first install : npm install uuid

    bucket.upload(filename, {
      destination,
      metadata: {
          metadata :{
            firebaseStorageDownloadTokens: uuidv4(),
         }
      },
    })

It doesn’t look like there’s anything that we can do in this repo to fix this issue. If it’s indeed an issue with the Console, please file a support issue at https://firebase.google.com/support

Come one, guys. You need external users to forward a breaking issue to another google team?

Hi, I was have same error, review google cloud console if very simple, no display in console because firebase console need firebaseStorageDownloadTokens, check example:

first install : npm install uuid

    bucket.upload(filename, {
      destination,
      metadata: {
          metadata :{
            firebaseStorageDownloadTokens: uuidv4(),
         }
      },
    })

THANK YOU!!!

@punisher97 Thank you so much !

@Punisher97 is there a way to do this in Python?

Hi, I was have same error, review google cloud console if very simple, no display in console because firebase console need firebaseStorageDownloadTokens, check example: first install : npm install uuid

    bucket.upload(filename, {
      destination,
      metadata: {
          metadata :{
            firebaseStorageDownloadTokens: uuidv4(),
         }
      },
    })

Is there a way to do this in Python? My code is currently:

localImage = 'generated_codes/' + qrString + '.png'
imageBlob = bucket.blob(qrString + '.png', )
imageBlob.upload_from_filename(localImage)

Hey! Sorry, have you found a way to do this?

upd: for those who will need it:

import uuid

token = uuid.uuid4()
# getting file_blob
file_blob.metadata = {"firebaseStorageDownloadTokens": token}
# upload file to storage
      metadata: {
          metadata :{
            firebaseStorageDownloadTokens: uuidv4(),
         }
      },

Thanks, works!

Hi, I was have same error, review google cloud console if very simple, no display in console because firebase console need firebaseStorageDownloadTokens, check example:

first install : npm install uuid

    bucket.upload(filename, {
      destination,
      metadata: {
          metadata :{
            firebaseStorageDownloadTokens: uuidv4(),
         }
      },
    })

Thank you so muchhh! ❤️

Hi, I was have same error, review google cloud console if very simple, no display in console because firebase console need firebaseStorageDownloadTokens, check example:

first install : npm install uuid

    bucket.upload(filename, {
      destination,
      metadata: {
          metadata :{
            firebaseStorageDownloadTokens: uuidv4(),
         }
      },
    })

You saved Hours! Awesome man.

Hi, I was have same error, review google cloud console if very simple, no display in console because firebase console need firebaseStorageDownloadTokens, check example:

first install : npm install uuid

    bucket.upload(filename, {
      destination,
      metadata: {
          metadata :{
            firebaseStorageDownloadTokens: uuidv4(),
         }
      },
    })

You literally just saved my life with this. Thanks!!!

Hey,

thank you very much for your long answer, even if it is off-topic in this thread. 😃

I really appreciate your effort to explain some insights and I also love firebase and the google cloud.

Google seems to have a lot of great talent inhouse, so it might be complicated for an non-googler like me to follow track of all the different departments and repositories. I did not quite totally get the line between firebase and the google cloud to name an example. And this is not my goal. My goal is to build great products easily, and this is why I use firebase: because it is much more easy to use than AWS.

So getting an issue like this, or googleapis/nodejs-storage#697 is irritating to me, especially when no easy solution seems to be around and this seems to root in the communication friction of the google departments. I don’t know the actual goal of firebase or google cloud, but if it is to make developers use their API and thus to make developers life easier, I see some low hanging fruits here. 😃

Still: Thanks a lot for the explanation and I really respect the level of code quality I constantly see in google products.

Nor the other way around? ;-P

I found this quite helpful: https://github.com/googleapis/nodejs-storage/issues/697#issuecomment-610603232

I couldn’t figure out how to label this issue, so I’ve labeled it for a human to triage. Hang tight.