使用gcloud for node.js如何公开分享谷歌云桶图像

时间:2016-09-07 17:52:02

标签: node.js image google-cloud-storage gcloud

要将图像存储在我的Google云端存储分区中,我使用@google-cloud/storage npm模块。现在我的图片上传成功了。我想公开分享,但在文档中没有提到参数。相反,我必须手动共享我的所有图像。有没有办法通过google-cloud / storage以编程方式公开分享图片?

2 个答案:

答案 0 :(得分:1)

要将现有对象标记为可公开阅读,请使用此示例from the docs

file.acl.add({
 entity: 'allUsers',
 role: gcs.acl.READER_ROLE
}, function(err, aclObject) {});

在进行上传时,要么像上面那样设置ACL,请使用预定义的ACL" publicRead",或者只指定选项" public"在呼叫上传时(请参阅docs for the upload method)。

答案 1 :(得分:0)

我使用了以下命令,它使我的存储桶默认公开共享。

IF('08/30/2015'>'08/29/2016')
SELECT '1'
ELSE
SELECT '0'