How to set file uploaded to publlic DO spaces?

Posted October 3, 2017 5.8k views

Each file I upload to my space is in private mode, how to make every file I upload to public.
my space is public but when i call files ACCESS DENIED

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
6 answers

Just add the ExtraArgs to it. This will make only the file accessible to the public.

client.uploadfile(filename, ‘xxxxxxx’, key, ExtraArgs={
'ACL’: 'public-read’

File permissions are independent of Space permissions at the moment. (Sorry, I know this is a bit confusing and we hope to be able to make this part of permissioning more intuitive in a future release.)

You will need to change all of your files to have the ‘Public’ permission if you’d like them to be world readable, regardless of how you’ve set your Space permission.

For Space permissions, 'Private’ means that the objects in the Space can’t be listed by non-authenticated (those without a valid Space key for the account) users. 'Public’ means that those files can be listed by anyone, regardless of whether or not they have a valid Spaces key for the account.

How to make the object public after its uploaded to space using api in python?
I am using below code snippet to upload file:

session1 = session.Session()
client = session1.client('s3',
client.upload_file(file_name, 'xxxxxxx', key)

I am also interested in this. That does not make sense to go manually over each file to set the permission. That turns DO Spaces out of the CDN idea.

This is a very important problem that needs a solution. Please answer. Thanks.

i know its been a really long time

but you can do this

client.upload_file(file_name, 'Bucket', 'object_name')
client.put_object_acl( ACL='public-read',  Bucket='Bucket', Key='object_name') #keep the  variables change only the values