1
votes

I've created an object inside a folder in Google Cloud Storage whith the following OptionsBuilder object:

GSFileOptionsBuilder optionsBuilder = new GSFileOptionsBuilder()
  .setBucket("bucket")
  .setKey("folder/obj.csv")
  .setMimeType("text/csv");

Making the next structure:

bucket >> folder >> obj.csv

When I run the gsutil command to get ACL for "bucket" and "obj.csv" works fine, however when I execute it for "folder" throws this exception: GSResponseError: status=404, code=NoSuchKey, reason=Not Found.

The exactly command I run is: gsutil getacl gs://bucket/folder/ > acl.txt

How I can get and set permissions on a folder?

1

1 Answers

5
votes

You can only retrieve the ACL of an object or a bucket. There is no such thing as a "folder" in GCS, so you can't set or get the ACL of a folder. I suggest you read the Concepts and Terminology section of the developer guide carefully. In particular, the section on object names:

Object names

An object name is just metadata to Google Cloud Storage. Object names can contain any combination of Unicode characters (UTF-8 encoded) less than 1024 bytes in length. A common character to include in file names is a slash (/). By using slashes in an object name, you can make objects appear as though they're stored in a hierarchical structure. For example, you could name one object /europe/france/paris.jpg and another object /europe/france/cannes.jpg. When you list these objects they appear to be in a hierarchical directory structure based on location; however, Google Cloud Storage sees the objects as independent objects with no hierarchical relationship whatsoever.