gpt4 book ai didi

google-app-engine - 在 Google Cloud Storage Go 运行时客户端 API 上公开新创建的文件

转载 作者:IT王子 更新时间:2023-10-29 02:34:09 29 4
gpt4 key购买 nike

我使用 Google Cloud Storage Go Runtime 客户端 API 将来自 GO 服务器的字符串写入默认存储桶中的文件。这是代码

wc := storage.NewWriter(d.ctx, bucket, fileName)
wc.ContentType = "text/plain"
if _, err := wc.Write([]byte(myData)); err != nil {
d.errorf("createFile: unable to write data to bucket %q, file %q: %v", bucket, fileName, err)
return
}

但我无法在 wc 对象上设置正确的 ACL 权限以使文件公开 ??如何实现它以便创建的文件公开?

最佳答案

尝试设置:

wc.ACL = []storage.ACLRule{{storage.AllUsers, storage.RoleReader}}

或者,您还可以更改存储桶上的默认对象 ACL,以便新创建的对象默认为公开可读。

关于google-app-engine - 在 Google Cloud Storage Go 运行时客户端 API 上公开新创建的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29247826/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com