更新:使用此 PR 中的代码修复了它,我已要求协助合并 PR,但现在我的问题是用 fork 排序的。
尝试通过以下包上传到谷歌云存储:
https://github.com/Superbalist/flysystem-google-cloud-storage#usage
我的集成在细粒度访问控制下运行良好,但我需要使用统一访问,并且任何时候我将其设置为统一而不是细粒度,我无法再上传到存储桶,并收到以下错误:
{
"error": {
"code": 400,
"message": "Cannot insert legacy ACL for an object when uniform bucket-level access is enabled. Read more at https://cloud.google.com/storage/docs/uniform-bucket-level-access.",
"errors": [
{
"message": "Cannot insert legacy ACL for an object when uniform bucket-level access is enabled. Read more at https://cloud.google.com/storage/docs/uniform-bucket-level-access.",
"domain": "global",
"reason": "invalid"
}
]
}
}
任何想法我可能会缺少让这个工作?
最佳答案
有一个公开的 PR 来解决这个问题 [ Allow uniform access rules on upload ]。
但是,在接受此 PR 之前,我曾经解决此问题,而不是通过使用 PHP 7 中提到的 PR 更改和匿名类来更新包文件本身
public function resolveAdapter ($storageClient, $bucket)
{
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;
}
};
}
关于php - 尝试使用 Superbalist/flysystem-google-cloud-storage 上传到 Google 云存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61779218/