首页 文章

如何使用GD图像功能设置Google Cloud 端存储ACL

提问于
浏览
0

我正在使用“imagepng”在我的应用程序中创建一些缩略图 .

如何为Google Cloud 端存储专门设置ACL,以便公开提供该文件?

我知道我可以将整个存储桶设置为这样,但我有兴趣能够为图像功能以及其他文件上传方法执行此操作(文档只讨论file_put_contents,我不使用)

1 回答

  • 2

    使用ACL "public-read" . 文档中有an example of serving such a thing . 例:

    $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);
    

相关问题