GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Storage example should show how to set ACL · Issue #1012 · googleapis/google-cloud-java

Storage example should show how to set ACL #1012

New issue
Copy link
New issue
Copy link
Closed
#1033
Closed
Storage example should show how to set ACL#1012
#1033
Copy link
Assignees
mziccard
Labels
api: storageIssues related to the Cloud Storage API.

Description

@volgin
volgin
opened on May 16, 2016
Issue body actions

ACLs are not even mentioned in the examples. Example needs to show both how to set a specific ACL and how to set a PredefinedAcl.

When I use this this code, the console Cloud Storage viewer does not show items as shared publicly:

storage.create(coverBlob, coverImage,
    BlobTargetOption.predefinedAcl(PredefinedAcl.PUBLIC_READ));

So it's not clear what this code is supposed to do.

Am I right to assume that ACL should be set on BlobInfo like this?

    .acl(Arrays.asList(Acl.of(User.ofAllUsers(), Role.READER)))

If this is correct, is it enough, or should be used together with BlobTargetOption.predefinedAcl(PredefinedAcl.PUBLIC_READ)?

Activity

  1. mziccard commented on May 16, 2016

    @mziccard
    mziccard
    on May 16, 2016
    Contributor
    More actions

    ACLs and predefined ACLs are concepts of Cloud Storage with a dedicated documentation page that should help you understand the different between ACLs and predefined ACLs. We kept the same name so that users familiar with Storage concepts should feel quite at home.

    The following code:

    storage.create(coverBlob, coverImage,
        BlobTargetOption.predefinedAcl(PredefinedAcl.PUBLIC_READ));

    Sets the predefined ACL to PUBLIC_READ, predefined ACLs are documented by the service here. The PUBLIC_READ predefined ACL corresponds to setting the following permissions:

    • Object owner gets OWNER access
    • allUsers get READER access

    I just tried the code and the created blob is correctly shown in the web Console as "Shared publicly".

    This other code:

    .acl(Arrays.asList(Acl.of(User.ofAllUsers(), Role.READER)))

    Sets the ACL for the blob (a much finer control is possible, when compared to the sole predefined ACLs). In your code you are just setting following permission:

    • allUsers get READER access

    Even in this second case the web Console correctly marks the blob as "Shared publicly".

    If your goal is to make a blob publicly available both codes will do it.

  2. mziccard
    added
    api: storageIssues related to the Cloud Storage API.
    docs
    on May 16, 2016
  3. volgin commented on May 17, 2016

    @volgin
    volgin
    on May 17, 2016
    Author
    More actions

    This is how objects look in my bucket when I upload them with the PredefinedAcl:

    screen shot 2016-05-17 at 1 16 51 am

    As you can see, Share Publicly checkbox is missing. Selecting objects and pressing "Share Publicly" button has no effect.

  4. mziccard commented on May 17, 2016

    @mziccard
    mziccard
    on May 17, 2016
    Contributor
    More actions

    As I said previously I tried this code (and several other combinations):

    storage.create(BlobInfo.builder("my-bucket", "test-acl").build(),
        BlobTargetOption.predefinedAcl(PredefinedAcl.PUBLIC_READ));
    
    storage.create(BlobInfo.builder("my-bucket", "test-acl-with-content").build(),
        "Hello, ACL!".getBytes(), BlobTargetOption.predefinedAcl(PredefinedAcl.PUBLIC_READ));

    And it works just fine:
    screen shot 2016-05-17 at 9 01 27 am

    Are you sure you are using the code you shared to create the blobs? If you then get them with cloud-java what does blob.acl() contain?

  5. volgin commented on May 17, 2016

    @volgin
    volgin
    on May 17, 2016
    Author
    More actions
    1. Yes, I copied the exact code that I use. The only difference with your code is how I create BlobInfo - note contectType:
    BlobInfo coverBlob = BlobInfo.builder("coverart", releaseId + ".jpg")
                        .contentType("image/jpeg")
                        .build();
    
    1. I tried accessing these images from an unauthenticated browser, and they do show up. So missing checkboxes from the Cloud Storage viewer is the only problem/source of confusion. You can try to access these objects - the bucket name is "coverart", and all the objects inside are public.

    Note that if I rename the object, the checkbox appears (unchecked, which is the expected behavior). Then I can check it as usual.

    screen shot 2016-05-17 at 12 10 27 pm

  6. aozarov commented on May 17, 2016

    @aozarov
    aozarov
    on May 17, 2016
    Contributor
    More actions

    Maybe @BrandonY has some insights why the Cloud Storage Viewer behaves that way.

  7. mziccard commented on May 17, 2016

    @mziccard
    mziccard
    on May 17, 2016
    Contributor
    More actions

    This is weird. Now I am experiencing the problem as well, and it seems not to be a problem with just the web console. If I create a blob:

    storage.create(BlobInfo.builder("my-bucket", "test-acl").build(),
            BlobTargetOption.predefinedAcl(PredefinedAcl.PUBLIC_READ));

    The HTTP response (to the uploading POST request) correctly has the expected ACLs:

    {
     "kind": "storage#object",
     "id": "my-bucket/test-acl/1463505795940000",
     "selfLink": "https://www.googleapis.com/storage/v1/b/my-bucket/o/test-acl",
     "name": "test-acl",
     "bucket": "my-bucket",
     "generation": "1463505795940000",
     "metageneration": "1",
     "contentType": "text/plain",
     "timeCreated": "2016-05-17T17:23:15.931Z",
     "updated": "2016-05-17T17:23:15.931Z",
     "storageClass": "STANDARD",
     "size": "0",
     "md5Hash": "1B2M2Y8AsgTpgAmY7PhCfg==",
     "mediaLink": "https://www.googleapis.com/download/storage/v1/b/my-bucket/o/test-acl?generation=1463505795940000&alt=media",
     "acl": [
      {
       "kind": "storage#objectAccessControl",
       "id": "some-id",
       "selfLink": "some-link",
       "bucket": "my-bucket",
       "object": "test-acl",
       "generation": "1463505795940000",
       "entity": "some-entity",
       "role": "OWNER",
       "entityId": "some-entity-id",
       "etag": "some-tag"
      },
      {
       "kind": "storage#objectAccessControl",
       "id": "my-bucket/test-acl/1463505795940000/allUsers",
       "selfLink": "https://www.googleapis.com/storage/v1/b/my-bucket/o/test-acl/acl/allUsers",
       "bucket": "my-bucket",
       "object": "test-acl",
       "generation": "1463505795940000",
       "entity": "allUsers",
       "role": "READER",
       "etag": "CKD93/jP4cwCEAE="
      }
     ],
     "owner": {
      "entity": "my-entity",
      "entityId": "my-entity-id"
     },
     "crc32c": "AAAAAA==",
     "etag": "CKD93/jP4cwCEAE="
    }

    However if I GET the object the ACLs disappeared:

    {
     "kind": "storage#object",
     "id": "empty-test-bucket/test-acl/1463505795940000",
     "selfLink": "https://www.googleapis.com/storage/v1/b/my-bucket/o/test-acl",
     "name": "test-acl",
     "bucket": "my-bucket",
     "generation": "1463505795940000",
     "metageneration": "1",
     "contentType": "text/plain",
     "timeCreated": "2016-05-17T17:23:15.931Z",
     "updated": "2016-05-17T17:23:15.931Z",
     "storageClass": "STANDARD",
     "size": "0",
     "md5Hash": "1B2M2Y8AsgTpgAmY7PhCfg==",
     "mediaLink": "https://www.googleapis.com/download/storage/v1/b/my-bucket/o/test-acl?generation=1463505795940000&alt=media",
     "crc32c": "AAAAAA==",
     "etag": "CKD93/jP4cwCEAE="
    }

    /cc @Capstan

  8. Capstan commented on May 17, 2016

    @Capstan
    Capstan
    on May 17, 2016
    Contributor
    More actions

    You need the full projection to get ACLs on normal gets. If you provide an ACL on create or update, you'll get an acl in the response, but otherwise you need to specify full there as well.

  9. mziccard commented on May 17, 2016

    @mziccard
    mziccard
    on May 17, 2016
    Contributor
    More actions

    @Capstan I am using full projection to get the blob.

    What I believe is happening is that the blobs are being created with a service account while the console is being accessed with a different account and thus has no access to the ACL information (@volgin can you confirm you are running this scenario?)

    For the console to show the "Shared publicly" mark I used:

    storage.create(BlobInfo.builder("my-bucket", "test-acl")
        .acl(Arrays.asList(Acl.of(User.ofAllUsers(), Acl.Role.READER),
            Acl.of(new User("[email protected]"), Acl.Role.OWNER))).build());

    Where "[email protected]" is the account I use to log to the web console. Or you could give owner access to all project owners:

    storage.create(BlobInfo.builder("my-bucket", "test-acl")
        .acl(Arrays.asList(
            Acl.of(User.ofAllUsers(), Acl.Role.READER),
            Acl.of(
                new Acl.Project(Acl.Project.ProjectRole.OWNERS, "your-project"),
                Acl.Role.OWNER))).build());

    @volgin regardless of the fact that you are not seeing the "Shared publicly" mark in the web console I believe they are being properly set.

  10. volgin commented on May 17, 2016

    @volgin
    volgin
    on May 17, 2016
    Author
    More actions

    @mziccard - You are correct.

    It looks like a bug in web console: I can do anything I want with these objects (rename and delete), which indicates Owner access level, but I do not see the checkbox for "Share publicly".

  11. mziccard
    closed this as completedin #1033on Jun 8, 2016
  12. JustinBeckwith
    assigned
    mziccard
    on Feb 1, 2021
  13. suztomo
    added a commit that references this issue on Feb 1, 2023

    chore(main): release 2.8.26 (#1012)

    a4f0795
  14. meltsufin
    added a commit that references this issue on Dec 22, 2025

    fix: Replace Date with LocalDateTime (#1012)

    765dd89
  15. chingor13
    added a commit that references this issue on Jan 6, 2026

    build(deps): bump cryptography from 38.0.3 to 39.0.1 in /synthtool/gc…

    d7dbf45
  16. chingor13
    added a commit that references this issue on Jan 22, 2026

    fix: flaky test com.google.datastore.snippets.ConceptsTest: testStale… (

    fc66d58
  17. chingor13
    added a commit that references this issue on Feb 24, 2026

    chore(deps): update dependency google-api-core to v2.10.1 (#1012)

    cd1911a
  18. suztomo
    added a commit that references this issue on Mar 11, 2026

    fix: Replace Date with LocalDateTime (googleapis#1012)

    771ea35
  19. chingor13
    added a commit that references this issue on Mar 12, 2026

    chore(deps): update dependency google-api-core to v2.10.1 (#1012)

    ef8bfd1
  20. suztomo
    added a commit that references this issue on Mar 23, 2026

    chore(main): release 2.7.11-SNAPSHOT (googleapis#1012)

    235667b
  21. meltsufin
    added 2 commits that reference this issue on Apr 29, 2026

    chore(main): release 1.115.5 (#1012)

    d2f0b05

    chore(main): release 1.115.5 (#1012)

    d414e61
  22. benjaminp
    added a commit that references this issue on Jul 13, 2026

    chore: release 2.1.3 (googleapis#1012)

    31d3d51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @mziccard
    mziccard

Labels

api: storageIssues related to the Cloud Storage API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.