【问题标题】:How to set Google Cloud Storage ACL with GD image functions如何使用 GD 图像功能设置 Google Cloud Storage ACL
【发布时间】:2015-02-27 14:09:19
【问题描述】:

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

如何专门设置 Google Cloud Storage 的 ACL 以使文件公开可用?

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

【问题讨论】:

    标签: php google-app-engine gd google-cloud-storage


    【解决方案1】:

    使用 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);
    

    【讨论】:

    • 啊。不幸的是,我不知道如何告诉 imagepng 在保存文件时如何指定 Content-Type,因此您需要在将图像保存为单独的操作后修改 Content-Type。
    猜你喜欢
    • 1970-01-01
    • 2020-02-17
    • 2015-02-15
    • 2015-11-16
    • 2013-04-30
    • 2018-06-06
    • 2014-10-09
    • 2017-10-08
    • 2016-11-09
    相关资源
    最近更新 更多