Skip to content

trouble with changing an access for blobs #1710

Closed

Description

@dev-priporov

I work with Google Storage API via java and I use 0.9.4-alpha(before was 0.9.2-alpha ) version. When I create a blob, I use this code and it works correctly, I get different access levels for a new blob:

bucket.create(
    getFileName(req),
    fileToInputStream(req),
    Bucket.BlobWriteOption.predefinedAcl(getPredefinedAcl(req.getAccessType()))
);

but I need to have an opportunity of changing an access to particular files. Well, I have supposed that it seems like this, because I didn't find any examples and information in the documentation:

blob.update(
    Storage.BlobTargetOption.predefinedAcl(Storage.PredefinedAcl.PRIVATE)
);

but this piece of code throws an exception: com.google.cloud.storage.StorageException: Cannot provide both a predefinedAcl and access controls. and I get a message:

{
    "code" : 409,
    "errors" : [ {
    "domain" : "global",
    "message" : "Cannot provide both a predefinedAcl and access controls.",
    "reason" : "conflict"
    } ],
    "message" : "Cannot provide both a predefinedAcl and access controls."
}

It seems to me it's weird because I can pass Storage.BlobTargetOption.predefinedAcl in update method, but it doesn't work(perhaps I have not to pass predefinedAcl there ...??).
Also I have tried to change an access via com.google.cloud.storage.Acl class but I got another exception.
I suppose I do something wrong and it isn't a bug, but stackoverflow didn't help me and absence of examples is really problem for me now. I should be grateful you for help.

Activity

  1. added
    api: storageIssues related to the Cloud Storage API.
    type: questionRequest for information or clarification. Not an issue.
    on Mar 8, 2017
  2. dev-priporov commented on Mar 9, 2017

    @dev-priporov
    Author

    well, I found a solution:

    Acl acl = Acl.of(Acl.User.ofAllUsers(), Acl.Role.READER);
    blob.createAcl(acl);
    blob.deleteAcl(acl.getEntity());
    

    But I think it's not as obvious as it can

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

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the Cloud Storage API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions