How to add domain to Google Cloud Storage object A

2019-07-09 05:36发布

In my Java based app-engine project, i allow users to upload files to google cloud store (this works), but i can't seem to add a specific domain to the access list, so that only people from within my company can access my files. How do i do this?

i tried using:

    GcsService gcsService = GcsServiceFactory.createGcsService(RetryParams.getDefaultInstance());
    GcsFilename gcsFileName = new GcsFilename("my-bucket", user_uploaded_file_name);
    Builder fileOptionsBuilder = new GcsFileOptions.Builder();
    fileOptionsBuilder.mimeType(mimeType);
    fileOptionsBuilder.acl("authenticated-read"); // how do i modify this list?
    GcsFileOptions fileOptions = fileOptionsBuilder.build();
    GcsOutputChannel outputChannel = gcsService.createOrReplace(gcsFileName, fileOptions);

and this authenticated-read just makes the file public (not what i want). i want to add everyone from the organization "@mycompany.com" to the access list. do i do this through code? or do i do this using the google cloud console?

I will be providing people the links to files they upload via this url:

String url = https://console.developers.google.com/m/cloudstorage/b/" + "my-bucket" + "/o/" + user_uploaded_file_name;

1条回答
家丑人穷心不美
2楼-- · 2019-07-09 06:03

Oh wow. this guy was really helpful and had a Java version:

Changing ACL for Google Cloud Storage from Appengine (JAVA)

this totally worked for me!

查看更多
登录 后发表回答