bashoogzaad bashoogzaad - 12 days ago 7
Java Question

Retrieve ACL of specific file with Google Cloud Storage Client Library for Java

I currently have the following problem:

I would like to check the access control list of an object in my bucket on Google Cloud Storage from my App Engine App. I know I can set the ACL with the

GcsFileOptions.Builder
, but I want to read it from a specific file before passing it to the user.

I am not able to find a method with which this is possible. Am I missing something here or is the Google Cloud Storage REST API the only way to do this? (https://cloud.google.com/storage/docs/xml-api/get-object-acls). In that case: can anyone explain why this method is not available in the client library?

Answer

Maybe I am also missing something, but isn't it through the getAcl method of the GcsFileOptions class?

https://cloud.google.com/appengine/docs/java/googlecloudstorageclient/javadoc/com/google/appengine/tools/cloudstorage/GcsFileOptions.html#getAcl--

You first get the file metadata through getMetadata() on the gcs service and then get the GcsFileOptions via metadata.getOptions()

Comments