Skip to content

Commit

Permalink
added mimetype as a content type args while uploading file to s3
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaurya committed Jan 15, 2024
1 parent 9cfe9d4 commit abe9c5e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fastapi_storages/s3.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from pathlib import Path
from typing import BinaryIO

import mimetypes
try:
import boto3
except ImportError: # pragma: no cover
Expand Down Expand Up @@ -110,8 +110,8 @@ def write(self, file: BinaryIO, name: str) -> str:

file.seek(0, 0)
key = self.get_name(name)

self._bucket.upload_fileobj(file, key, ExtraArgs={"ACL": self.AWS_DEFAULT_ACL})
mimetype = mimetypes.guess_type(key)
self._bucket.upload_fileobj(file, key, ExtraArgs={"ACL": self.AWS_DEFAULT_ACL,"ContentType": mimetype})
return key

def generate_new_filename(self, filename: str) -> str:
Expand Down

0 comments on commit abe9c5e

Please sign in to comment.