Skip to content

Commit

Permalink
fix(CORS): Allow objects to be uploaded & download from everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
qgerome committed Jul 11, 2024
1 parent 526c35f commit eeafebc
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 46 deletions.
16 changes: 1 addition & 15 deletions hexa/files/gcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,21 +131,7 @@ def create_bucket(self, bucket_name: str, labels: dict = None, *args, **kwargs):

bucket.labels = labels

bucket.cors = [
{
"origin": settings.CORS_ALLOWED_ORIGINS,
"responseHeader": [
"Authorization",
"Content-Range",
"Accept",
"Content-Type",
"Origin",
"Range",
],
"method": ["GET", "PUT"],
"maxAgeSeconds": 3600,
}
]
bucket.cors = []
bucket.patch()

return bucket
Expand Down
31 changes: 0 additions & 31 deletions hexa/files/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,37 +117,6 @@ def create_bucket(self, bucket_name: str, *args, **kwargs):
Bucket=bucket_name,
CreateBucketConfiguration={"LocationConstraint": default_region},
)

# Define the configuration rules
cors_configuration = {
"CORSRules": [
{
"AllowedHeaders": [
"Authorization",
"Content-Range",
"Accept",
"Content-Type",
"Origin",
"Range",
],
"AllowedMethods": ["GET", "PUT"],
"AllowedOrigins": settings.CORS_ALLOWED_ORIGINS,
"ExposeHeaders": [
"ETag",
"x-amz-request-id",
"Authorization",
"Content-Range",
"Accept",
"Content-Type",
"Origin",
"Range",
],
"MaxAgeSeconds": 3000,
}
]
}

s3.put_bucket_cors(Bucket=bucket_name, CORSConfiguration=cors_configuration)
return S3BucketWrapper(bucket_name)
except s3.exceptions.ClientError as exc:
# https://github.com/VeemsHQ/veems/blob/3e2e75c3407bc1f98395fe94c0e03367a82852c9/veems/media/upload_manager.py#L51C1-L51C1
Expand Down

0 comments on commit eeafebc

Please sign in to comment.