google-cloud-php icon indicating copy to clipboard operation
google-cloud-php copied to clipboard

File Uploaded with predefinedAcl publicRead generating Auth Error

Open randinterval opened this issue 8 years ago • 3 comments

Hi,

I'm uploading files to Google Cloud Storage bucket using Google Cloud PHP SDK:

       $object= $this->bucket->upload(
            fopen('pdfs/'.$file,'r'),[
                'name' => $path.$file,
                'predefinedAcl' => 'publicRead'
          ]
        );

After uploading the file, I get back the mediaLink from reponse object. It has been working fine for over a year, however lately I'm encountering an extremely weird issue i.e sometimes the mediaLink works (without auth) and sometimes it doesn't. The files uploaded through the above method starts generating auth errors:

Anonymous caller does not have storage.objects.get access to xyz.appspot.com/files/abc/def/1536066134246.pdf.

As you can see in the code, the Access Control List scope is Public Read so it should definitely work without auth.

I have not been able to reproduce this issue because it's quite random. Sometimes, this error pops up right after file upload and sometimes file works for random period of time and then starts generating authentication errors.

The bucket is default firebase storage bucket. There is no lifecycle management configuration assigned to the bucket.

randinterval avatar Sep 10 '18 08:09 randinterval

@randinterval when you start to receive the error, does it persist on that link indefinitely or is this a temporary issue?

dwsupplee avatar Sep 13 '18 17:09 dwsupplee

It has been happening since last two months (randomly) and yes, it does persist.

randinterval avatar Sep 13 '18 17:09 randinterval

I've been testing this out and haven't been able to reproduce. Could there be any other code which may be inadvertently removing the permissions? Turning on logging might be able to help narrow down what is occurring.

dwsupplee avatar Sep 13 '18 19:09 dwsupplee