英文:
Marking inserted objects as public with GoLang Google Cloud Storage API
问题
我正在使用Golang的storage v1包将文件上传到Google Cloud Storage,使用以下方法:
func (r *ObjectsService) Insert(bucket string, object *Object) *ObjectsInsertCall
Insert: 存储一个新的对象和元数据。
除了我不确定如何公开暴露上传的文件,使用Google的开发者控制台,我可以通过点击“公共链接”复选框手动设置文件为公开。
有什么办法可以使用上述API实现相同的结果吗?如果有示例,将不胜感激。
英文:
I'm using Golang package storage v1 to upload files to Google Cloud Storage,
using the following method:
func (r *ObjectsService) Insert(bucket string, object *Object) *ObjectsInsertCall
Insert: Stores a new object and metadata.
Everything works great except I'm not sure how to publicly expose uploaded files, using Google's developers console I can manually set a file public by clicking the Public link checkbox,
Any idea how do I achieve the same result using the above API? an example would be highly appreciated
答案1
得分: 2
ObjectsInsertCall中有一个PredefinedAcl函数。预定义的ACL在API文档中有描述,其中之一是"public-read",它将对象标记为全局可查看。
英文:
There's a PredefinedAcl function on ObjectsInsertCall. Predefined ACLs are described in the API documentation, but one of them is "public-read", which marks the object as globally viewable.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论