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.

Submit an answer

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!