Report this

What is the reason for this report?

Downloading private files from Spaces CDN using boto3

Posted on April 7, 2020

I just enabled CDN access for my Spaces and was previously using the following to download private objects from the buckets using boto3:

S3_REGION = 'sfo2'
S3_ENDPOINT = 'https://sfo2.digitaloceanspaces.com'
S3_BUCKET = 'mybucket'

AWS_ACCESS_KEY_ID = 'xxx'
AWS_SECRET_ACCESS_KEY = 'zzz'

amzn_s3 = boto3.resource('s3', \
                        region_name=S3_REGION, \
                        endpoint_url=S3_ENDPOINT, \
                        aws_access_key_id=AWS_ACCESS_KEY_ID, \
                        aws_secret_access_key=AWS_SECRET_ACCESS_KEY)
bucket = amzn_s3.Bucket(S3_BUCKET)
bucket.download_file('remote_file.tar.gz', 'local_file.tar.gz')

How do I pull private objects from CDN? I’ve tried a bunch of variations of S3_REGION and S3_ENDPOINT but can’t seem to make any progress.



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!

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.