简体   繁体   English

Google Cloud Storage Java API-删除文件

[英]Google Cloud Storage Java API - Deleting a file

How do I set a "WRITER" permission on a GCS bucket? 如何在GCS存储桶上设置“写作者”权限?

I am trying to delete a file on cloud storage using: 我正在尝试使用以下方法删除云存储上的文件:

cloudstorage.objects().delete(bucket, object).execute();

and get the following error: 并得到以下错误:

{
  "code" : 403,
  "errors" : [ {
    "domain" : "global",
    "message" : "Forbidden",
    "reason" : "forbidden"
  } ],
  "message" : "Forbidden"
}

With gsutil, like this: 使用gsutil,如下所示:

gsutil acl ch -u email@address.com:W gs://bucket-name 

Alternately, you can go to the Developer's Console , head over to storage > Cloud Storage > Storage browser, click on the "...", then "edit bucket permissions", then click "+ Add item", choose "user", the email address, and Writer, then click "Save". 或者,您可以转到开发人员控制台 ,转到存储>云存储>存储浏览器,单击“ ...”,然后单击“编辑存储桶权限”,然后单击“ +添加项目”,选择“用户”,电子邮件地址和Writer,然后单击“保存”。

Alternately, you can do this programmatically with the JSON API, using the storage.bucketAccessControls.insert method. 或者,您可以使用storage.bucketAccessControls.insert方法通过JSON API以编程方式执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM