How to reference Google Cloud Storage image with "img src" (link direct to the image)

StackOverflow https://stackoverflow.com/questions/23485102

  •  16-07-2023
  •  | 
  •  

Question

Say I do this

./gsutil cp /home/blah/blah/post-images/google/cube.jpg gs://(bucket-name)/google/cube.jpg

The image is supposed to be here

<img src="https://console.developers.google.com/storage/(bucket-name)/google/cube.jpg

(as per https://developers.google.com/storage/docs/access-public-data) but it doesn't work...

That URL is fine if you want to see the image in the "bucket" and browse the bucket's directory structure, but useless if you want to link to the image directly.

I can go here https://console.developers.google.com/m/cloudstorage/b/(bucket-name)/o/google/cube.jpg to link directly to the image, BUT is this "/m/cloudstorage/b/" an arbitrary location or can I always find my images in there? Also what is "/o/" that's not a subdirectory I created. Are these random letters of the alphabet or is there a method to Google's madness or is it always "/o/" ?

In short, what's the correct way to directly link to my Google Cloud Storage images?

Was it helpful?

Solution

That URL is for the developer's console UI.

See Request URIs for a list of access points.

You probably want:

https://storage.googleapis.com/bucketname/google/cube.jpg
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top