deliciousbrains / wp-amazon-s3-and-cloudfront

Automatically copies media uploads to Amazon S3 for delivery. Optionally configure Amazon CloudFront for even faster delivery.
https://wordpress.org/plugins/amazon-s3-and-cloudfront/
312 stars 150 forks source link

GCP - StreamWrapper issues. #628

Open stephenheron opened 1 year ago

stephenheron commented 1 year ago

Hello!

We noticed an issue with using Google Cloud Storage and the 'StreamWrapper'. When new files were created using the StreamWrapper method, the permissions of the new files were set to ‘Private’ rather than ‘Public’.

After quite a while investigating, I think I know what the issue is.

If we look in the S3 wrapper, at the stream_flush function, it appears to handle the permissions by using ‘stream_context_set_option’ which the StreamWapper uses internally to get the ACL.

The GCP wrapper doesn’t seem to have anything similar. I used the S3 wrapper as a basis but added the code to the register function and I also had to change the option from ‘ACL’ to ‘predefinedAcl’.

Updated code can be found here: https://gist.github.com/stephenheron/c4c775f11a1fbe19825139e041729cf7

I was going to open a pull request, but it seems like you don’t accept them in this repo.

Not quite sure if it’s the right approach but it’s my best guess.

Thanks, Stephen