Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Documentation Issue] Document and provide code snippets for setting the ACL on an object #1414

Closed
faustoibarra opened this issue Jan 22, 2016 · 3 comments
Assignees
Labels
api: storage Issues related to the Cloud Storage API. priority: p2 Moderately-important priority. Fix may not be included in next release.

Comments

@faustoibarra
Copy link

Page Name: storage-acl
Release: 0.8.0

Please add an explanation and code snippet to illustrate how to set the ACL for an object. The referenced page only talks about setting bucket-level permissions, and it isn't easy to find whether a blob object also has the acl property, and whether it works the same way as it does with buckets. I would suggest a code snippet such as the one below, which uploads a new blob and sets its ACL to "public read". It's also important to note that the blob needs to be uploaded before its ACL can be set (i.e. if I move the upload_from_string() command below acl.save(), the latter will not have any effect, nor will it fail with any errors).

def put_object(bucket_name, object_name, object, public_read = True):
    client = storage.Client(PROJECT)
    bucket = client.get_bucket(bucket_name)
    blob = bucket.blob(object_name)
    blob.upload_from_string(object,content_type = 'image/jpeg', client = client)
    # set ACL to public-read so the image can be accessed by any user
    if (public_read):
        acl = blob.acl
        acl.all().grant_read()
        acl.save()
@faustoibarra faustoibarra changed the title [Documentation Issue] [Documentation Issue] Document and provide code snippets for setting the ACL on an object Jan 22, 2016
@dhermes dhermes added api: storage Issues related to the Cloud Storage API. docs labels Jan 22, 2016
@jgeewax
Copy link
Contributor

jgeewax commented Jan 25, 2016

I think there's a larger discussion of changing how we do ACLs in general. Regardless of that, yes, we need to add snippets for the "common use cases" for object as well as buckets.

@lukesneeringer lukesneeringer added the priority: p2 Moderately-important priority. Fix may not be included in next release. label Apr 19, 2017
@albertpadin
Copy link

+1

I also suggest adding a code snippet in the documentation. This is a common use case and I just spent a few hours running into error after error trying to figure it out.

Thanks! :)

@lukesneeringer
Copy link
Contributor

Hello,
One of the challenges of maintaining a large open source project is that sometimes, you can bite off more than you can chew. As the lead maintainer of google-cloud-python, I can definitely say that I have let the issues here pile up.

As part of trying to get things under control (as well as to empower us to provide better customer service in the future), I am declaring a "bankruptcy" of sorts on many of the old issues, especially those likely to have been addressed or made obsolete by more recent updates.

My goal is to close stale issues whose relevance or solution is no longer immediately evident, and which appear to be of lower importance. I believe in good faith that this is one of those issues, but I am scanning quickly and may occasionally be wrong. If this is an issue of high importance, please comment here and we will reconsider. If this is an issue whose solution is trivial, please consider providing a pull request.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API. priority: p2 Moderately-important priority. Fix may not be included in next release.
Projects
None yet
Development

No branches or pull requests

5 participants