Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Cloud Storage public link does not become invalid when unchecking

I am using Google Cloud Storage to upload images. I am now testing it from the cloud console. After I upload a picture if I check the Share publicly checkbox to obtain a public link, I get (obviously) a publicly accessible url, which is: https://storage.googleapis.com/bucket_name/pictureName .

Then, if I uncheck the Share Publicly checkbox, it makes a request

Request URL:https://clients6.google.com/storage/v1_internal/b/bucketName/o/pictureName.jpg/acl/allUsers?key=AIzaSyCI-yuie5UVOi0DjtiCwWBwQ1djkiuo1g
Request Method:DELETE

The request goes well, but the public url remains publicly accessible. I thought it is valid for some time, but after one hour is still available. So, what is the right way to remove the public url? How do I restrict access to a stored file after I made it public?

like image 963
Roxana Roman Avatar asked Jun 21 '16 13:06

Roxana Roman


3 Answers

See the documentation on cache control and consistency. In particular:

Note: If you do not specify a cache lifetime, a publicly accessible object can be cached for up to 60 minutes.

So I'm guessing this is working as intended and your object is cached. Have you tried waiting a little longer?

like image 86
jterrace Avatar answered Nov 15 '22 09:11

jterrace


In Sharing your data publicly, it's shown that there are 2 ways to stop sharing an object publicly.

  1. Deselect the checkbox under Shared Publicly as you've mentioned already.
  2. Edit the object permissions and remove the entry with ID allUsers.

The reason you are still able to access the object publicly is indeed because of caching as mentioned by @jterrace. The Cache control and consistency article referenced explains the effect of this eventual consistency.

One can test this behavior by sharing an object publicly and unsharing immediately after. In most cases, the object will be publicly accessible for the cache duration. One can shorten this duration by specifying the Cache-Control headers such as max-age.

like image 40
Nicholas Avatar answered Nov 15 '22 07:11

Nicholas


When Your sharing Publicly Url is like https://storage.googleapis.com/bucket_name/pictureName.

If you delete the file or uncheck the Share Publicly checkbox It is available up to 60 minutes it is default cache time in Google cloud,

To avoid the Issue Need to pass Query parameter like https://storage.googleapis.com/bucket_name/pictureName?avoidCache=1

Every time passes random number in a query string.

like image 34
Srinu Chilukuri Avatar answered Nov 15 '22 08:11

Srinu Chilukuri