By skeddtemp
I’m using a software that automatically puts files into my Space, but it makes them private, and I want them to be public. Is there any way to do this?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there,
What is the software that you are using to upload your files to Spaces?
For example, if you are using Python the bellow code snippet should allow you to upload a file and make it public:
from boto3.session import Session
def upload_file_and_make_it_public(filename: str, file_obj: BytesIO, bucket: str):
session = Session(
aws_access_key_id="...",
aws_secret_access_key="...",
region_name="...",
)
client = session.client(
"s3", endpoint_url="https://...digitaloceanspaces.com", region_name="...",
)
client.upload_fileobj(Bucket=bucket, Key=filename, Fileobj=file_obj)
resource = session.resource(
"s3", endpoint_url="https://....digitaloceanspaces.com", region_name="...",
)
resource.Object(bucket, filename).Acl().put(ACL='public-read')
There are a few more code snippets for different languages in the comments here:
https://www.digitalocean.com/community/questions/how-to-make-my-spaces-public
Best,
Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.