diff --git a/storages/s3_storage.py b/storages/s3_storage.py index ceb75c1..b124aae 100644 --- a/storages/s3_storage.py +++ b/storages/s3_storage.py @@ -1,4 +1,4 @@ -import uuid, os +import uuid, os, mimetypes from dataclasses import dataclass import boto3 @@ -21,6 +21,7 @@ class S3Config: private: bool = False key_path: str = "default" # 'default' uses full naming, 'random' uses generated uuid + class S3Storage(Storage): def __init__(self, config: S3Config): @@ -70,4 +71,5 @@ class S3Storage(Storage): extra_args = kwargs.get("extra_args", {}) else: extra_args = kwargs.get("extra_args", {'ACL': 'public-read'}) + extra_args['ContentType'] = mimetypes.guess_type(key)[0] self.s3.upload_fileobj(file, Bucket=self.bucket, Key=self._get_path(key), ExtraArgs=extra_args)