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 browser , how can I view the image instead of downloading it. I use the following URL for the uploaded image.
https://www.googleapis.com/download/storage/v1/b/image-downloader-bucket/o/a06266f6-6082-468e-92ca-f918a48533a8?generation=1455661996337000&alt=media
Can someone let me know how to create the right URL for viewing the image ?
If the object is publicly readable, you can view it directly at "https://storage.googleapis.com/BUCKET_NAME/OBJECT_NAME", which in your case would be https://storage.googleapis.com/image-downloader-bucket/a06266f6-6082-468e-92ca-f918a48533a8.
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"
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With