1

I am uploading an image on my server side in node js using firebase-admin package:

const upload = await bucket.upload('myimage.png', {
    destination: "myimage.png",
    metadata: {
        contentType: 'image/png'
    }
});

and it does not work, the file uploaded successfully but the firebase storage cannot read it as an image even though the content type is as I set in the matadata.

When I upload the same image manually it does read it as a png image.

Please help :) thanks

2
  • "the firebase storage cannot read it as an image" => how do you try to read it? Through the Firebase console? Commented Aug 29, 2020 at 14:21
  • it is not displayable in the firebase storage page Commented Aug 29, 2020 at 16:08

1 Answer 1

2

The Firebase console uses the download URL of images to display them. When you upload an image through the Admin SDK, it's using the Node.js SDK for Cloud Storage underneath and this SDK does not generate download URLs, so the Firebase console can't display images uploaded this way.

See this issues in the Github repo of the Admin SDK for more information. It also contains a workaround/solution. I haven't tried it myself, but it looks promising.

Another workaround seems to be in this answer: Cloud Functions: Resized images not loading

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.