How to view an image stored in Google cloud storage bucket?

前端 未结 4 1470
无人及你
无人及你 2020-12-20 14:51

I have a bucket that has images stored in it , when I retrieve the image using the public URL of the image it downloads it in the browser instead of showing the image in the

4条回答
  •  悲&欢浪女
    2020-12-20 15:09

    My problem was that I wasn't setting the mimetype for the object. Without it, the browser didn't know it was an image, so it was downloading the file instead of displaying it in the browser window

    Adding this did the trick:

    const blobStream = blob.createWriteStream({
      metadata: {
        contentType: "image/jpeg"
      }
    });
    

提交回复
热议问题