使用GoLang的Google Cloud Storage API将插入的对象标记为公共对象。

huangapple go评论78阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2014年11月11日 05:47:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/26853591.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定