I want to generate an URL for accessing the images in the bucket in Google Cloud Storage, as I want to reference it in img src tag of html. The reason is that we don’t store the image in server.
How can I achieve the following using java?
- Generate URL to reference the image in my bucket of Google Cloud Storage,
https://storage.cloud.google.com/my-bucket-name/myImage.jpg
. - This URL could be used to get the reference to src of img tag but the problem is only the ones who are signed in to google are able to view else it would ask for sign in first.
But what I observed is when I paste the above url in the browser, I find that the URL gets changed to some random url like below, and with this below url anybody can view the image without sign in and I feel if I could generate this URL using java I may be able to resolve the problem.
URL is as below (random fake URL)
https://00e9e544fb-apidata.googleusercontent.com/download/storage/v1/b/my-bucket-name/o/myImage.jpg?qk=AD5-vreOG-Y-RsJ0DZuI--owy_O_cx1RQy_Ya_kn0A_T-i-T-3xhg