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
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"
}
});
Similar to the @ehero response but for python, the point is using content_type blob attribute before uploading the file:
from google.cloud import storage
storage_client = storage.Client.from_service_account_json('your/path/to/service/credentials.json')
bucket = storage_client.bucket('my-bucket-name')
blob = bucket.blob('my/path/in/storage.jpg')
blob.content_type = 'image/jpeg' # This one is the important
blob.upload_from_file(file) # Also available upload_from_filename
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.
Yes there is! You actually resize the image of your file stored in Google Cloud Storage thru the Images API. Have a look at this link:
https://cloud.google.com/appengine/docs/java/images/