Question

How can I make all files in a folder in a Space public?

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?


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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