flysystem-google-cloud-storage icon indicating copy to clipboard operation
flysystem-google-cloud-storage copied to clipboard

Allow uniform access rules on upload

Open mattfoster7 opened this issue 4 years ago • 8 comments

Currently the code forces an ACL on the files, this doesn't work if the bucket has uniform access policies set. So this PR just checks whether the bucket has uniform access before setting the ACL.

mattfoster7 avatar Aug 10 '20 20:08 mattfoster7

The tests are failing because they are not scoped to work with this use case.

mattfoster7 avatar Aug 11 '20 13:08 mattfoster7

thanks @mattfoster7 for sharing this. however , and until merging this I used your solution as a work around using Anonymous classes in PHP7

return new class ($storageClient, $bucket) extends GoogleStorageAdapter {
    protected function getOptionsFromConfig(\League\Flysystem\Config $config)
    {
        $options = [];

        if (empty($this->bucket->info()['iamConfiguration']['uniformBucketLevelAccess']['enabled'])) {
            if ($visibility = $config->get('visibility')) {
                $options['predefinedAcl'] = $this->getPredefinedAclForVisibility($visibility);
            } else {
                $options['predefinedAcl'] = $this->getPredefinedAclForVisibility(AdapterInterface::VISIBILITY_PRIVATE);
            }
        }

        if ($metadata = $config->get('metadata')) {
            $options['metadata'] = $metadata;
        }

        return $options;
    }
};

7snovic avatar Sep 02 '20 12:09 7snovic

Shouldn't the visibility config be optional? Instead of defaulting to private?

This way user can omit the configuration if they don't want to use the predefinedAcl option.

theanchorsmith avatar Sep 05 '20 11:09 theanchorsmith

Any news on this?

Just for reference, this is the related question on StackOverflow: https://stackoverflow.com/questions/61779218/trying-to-upload-to-google-cloud-storage-using-superbalist-flysystem-google-clou

Aerendir avatar Nov 19 '20 10:11 Aerendir

Also curious about this one.

atrauzzi avatar Jul 11 '21 20:07 atrauzzi

Hi is there any progress with this pr? itd be great to get this change merged in!

JesseChua94 avatar Nov 04 '21 18:11 JesseChua94

Hi, is this pr alive? This will solve problems for who can't change bucket access control 🙏

GiusWhite avatar Jul 04 '22 14:07 GiusWhite

😭😭😭 Pls merge this pr🙏

tai221 avatar Mar 15 '23 02:03 tai221