[英]Trying to upload to Google cloud storage using Superbalist/flysystem-google-cloud-storage
更新:使用此 PR 中的代码修复了它,我已要求协助合并 PR,但现在我的问题是用叉子排序的。
尝试通过以下 package 上传到 Google 云存储:
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 来解决这个问题 [ 允许上传时统一访问规则]。
但是,在接受此 PR 之前,我曾经使用 Z2FEC392304A5C23AC17CZ 22847F7B 中提到的 PR 更改和匿名 class 来解决此问题,而不是更新 package 文件本身
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;
}
};
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.