Created
April 18, 2018 12:19
-
-
Save AJLeonardi/ea2a79223c10728dc1172d7c3ed1a198 to your computer and use it in GitHub Desktop.
DreamObjects boto3 CORS config for fonts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
session = boto3.session.Session() | |
connection = session.resource( | |
's3', | |
aws_access_key_id= '...', #dreamObjects key | |
aws_secret_access_key= '...', #dreamObjects secret key | |
endpoint_url= 'https://objects-us-west-1.dream.io', | |
) | |
client = connection.meta.client | |
cors_configuration = { | |
'CORSRules': [ | |
{ | |
'AllowedHeaders': ['Content','Host'], | |
'AllowedMethods': ['GET', 'HEAD'], | |
'AllowedOrigins': ['https://www.?.com', 'https://?.com', 'http://www.?.com', 'http://?.com'], | |
'ExposeHeaders': ['ETag'], | |
'MaxAgeSeconds': 86400 | |
} | |
] | |
} | |
#my-bucket-name is the name of an existing bucket | |
client.put_bucket_cors(Bucket='my-bucket-name', CORSConfiguration=cors_configuration) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment