spatie / laravel-google-cloud-storage

Google Cloud Storage filesystem driver for Laravel
https://spatie.be/open-source
MIT License
196 stars 51 forks source link

"Cannot insert legacy ACL for an object when uniform bucket-level access is enabled" #16

Closed ultrono closed 2 years ago

ultrono commented 2 years ago

Hi,

This is not so much an issue more of a suggestion to explain a frustrating edge case when uploading files.

If uploading to a bucket where uniform access is enabled and the visibility setting within the package confguration is publicor private, a League\Flysystem\UnableToWriteFile exception will be thrown, stating Unable to write file at location.

If you follow this exception to League\Flysystem\GoogleCloudStorage@upload() the actual exception states: Cannot insert legacy ACL for an object when uniform bucket-level access is enabled.

This situation is already handled by Flysystem, see https://github.com/thephpleague/flysystem/pull/1357.

The fix here is to set the visibility within the file system config as follows:

'visibility' => 'noPredefinedVisibility',

Note the string is a constant within the Flysystem repository at https://github.com/thephpleague/flysystem/blob/3.x/src/GoogleCloudStorage/PortableVisibilityHandler.php#L14 and could be therefore be defined as:

use League\Flysystem\GoogleCloudStorage\PortableVisibilityHandler;
// ..
'visibility' => PortableVisibilityHandler::NO_PREDEFINED_VISIBILITY,

Would you accept an update to the package readme that briefly explains this, as noPredefinedVisibility is not mentioned.

Thanks

ultrono commented 2 years ago

Actually as it's a small documentation change I created a PR: #17