Febian Shah
Febian Shah

Reputation: 1007

Google Cloud Storage Java API - Deleting a file

How do I set a "WRITER" permission on a GCS bucket?

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"
}

Upvotes: 1

Views: 1632

Answers (1)

Brandon Yarbrough
Brandon Yarbrough

Reputation: 38389

With gsutil, like this:

gsutil acl ch -u [email protected]: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".

Alternately, you can do this programmatically with the JSON API, using the storage.bucketAccessControls.insert method.

Upvotes: 2

Related Questions