如何使用 PredefinedAcl 函数将 ACL 设置为 publicRead?

How to set the ACL to publicRead with PredefinedAcl function?

if res, err := service.Objects.Insert(*bucketName, object).Media(file).Do(); err == nil {
     fmt.Printf("Created object %v at location %v\n\n", res.Name, res.SelfLink)
} else {
     fatalf(service, "Objects.Insert failed: %v", err)
}

我想修改此代码以将 ACL 设置为 publicRead,我注意到 API func (*ObjectsInsertCall) PredefinedAcl 中有一个函数,但我找不到如何使用它。

按照 what i found in the docs,看起来这样就可以了...

if res, err := service.Objects.Insert(*bucketName, object).Media(file).PredefinedAcl("publicRead").Do(); err == nil {
    fmt.Printf("Created object %v at location %v\n\n", res.Name, res.SelfLink)
} else {
    fatalf(service, "Objects.Insert failed: %v", err)
}

(在 Do() 调用之前插入。)HTH、YMMV 等