如何设置带有GD镜像功能的谷歌云存储ACL


How to set Google Cloud Storage ACL with GD image functions

我正在使用"imagepng"在我的应用程序中创建一些缩略图。

我如何为谷歌云存储专门设置ACL,使文件公开可用?

我知道我可以将整个bucket设置为这样,但我感兴趣的是能够为图像函数以及其他文件上传方法(文档只谈论file_put_contents,我没有使用它)做到这一点

使用ACL"public read"。文档中有一个提供此类服务的示例。示例:

$options = [ "gs" => [ "Content-Type" => $fileType, "acl"=>"public-read" ]];
$ctx = stream_context_create($options);
file_put_contents("gs://hooliapp.appspot.com/".$fileName, $file, 0, $ctx);
$object_public_url = CloudStorageTools::getPublicUrl('gs://hooliapp.appspot.com/'.$fileName, true);