Skip to content

trouble with changing an access for blobs #1710

@dev-priporov

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.

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