【发布时间】:2015-02-27 14:09:19
【问题描述】:
我正在使用“imagepng”在我的应用程序中创建一些缩略图。
如何专门设置 Google Cloud Storage 的 ACL 以使文件公开可用?
我知道我可以将整个存储桶设置为这样,但我有兴趣为图像功能以及其他文件上传方法执行此操作(文档只讨论 file_put_contents,我'我没有使用)
【问题讨论】:
标签: php google-app-engine gd google-cloud-storage
我正在使用“imagepng”在我的应用程序中创建一些缩略图。
如何专门设置 Google Cloud Storage 的 ACL 以使文件公开可用?
我知道我可以将整个存储桶设置为这样,但我有兴趣为图像功能以及其他文件上传方法执行此操作(文档只讨论 file_put_contents,我'我没有使用)
【问题讨论】:
标签: php google-app-engine gd google-cloud-storage
使用 ACL“公共读取”。文档中有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);
【讨论】: