[英]Flysystem Google Cloud Storage adapter Uniform Bucket
我正在尝试使用带有 flysystem v3 的制服。
https://flysystem.thephpleague.com/docs/adapter/google-cloud-storage/
$clientOptions = [
'projectId' => "project-id",
"keyFile" => "file.json",
];
$storageClient = new \Google\Cloud\Storage\StorageClient($clientOptions);
$bucket = $storageClient->bucket("bucket_name");
$fs = new \League\Flysystem\Filesystem(new \League\Flysystem\GoogleCloudStorage\GoogleCloudStorageAdapter($bucket, ''));
$fs->write("xx.txt" , "xx");
当我尝试写东西时,我得到“无法在位置写入文件:xx.txt”。 如果我切换到细粒度的一切工作正常。
知道我在做什么错吗? 我想有一些选项我没有正确传递。
这是我脱发后得到的解决方案:)
$storageClient = new \Google\Cloud\Storage\StorageClient($clientOptions);
$this->bucket = $storageClient->bucket($this->settings["set_bucket"]);
//uniform bucket
if (!empty($this->bucket->info()['iamConfiguration']['uniformBucketLevelAccess']['enabled'])) {
$config = [
'visibility' => "noPredefinedVisibility",
'directory_visibility' => "noPredefinedVisibility",
];
} else {
$config = "";
}
$this->fs = new \League\Flysystem\Filesystem(
new \League\Flysystem\GoogleCloudStorage\GoogleCloudStorageAdapter(
$this->bucket,
''
),
$config
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.