diff --git a/.idea/misc.xml b/.idea/misc.xml
index ed4c707..96c631b 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,5 +3,5 @@
-
+
\ No newline at end of file
diff --git a/.idea/sharpei.iml b/.idea/sharpei.iml
index 66cbf2d..1d5a2ae 100644
--- a/.idea/sharpei.iml
+++ b/.idea/sharpei.iml
@@ -3,8 +3,9 @@
+
-
+
diff --git a/sharpei/handler.py b/sharpei/handler.py
index 0d7d783..2300833 100644
--- a/sharpei/handler.py
+++ b/sharpei/handler.py
@@ -2,6 +2,7 @@
from os import path
from typing import Union
import logging
+import mimetypes
from watchdog import events
import boto3
@@ -42,11 +43,16 @@ def _relative_s3_filename(self, filename: str) -> str:
def s3_upload(self, file_path: str):
upload_key = self.base_key + self._relative_s3_filename(file_path)
logger.info(f"Upload {file_path} to s3://{self.bucket}/{upload_key}")
+ extra_args = self.s3_args.copy()
+ mimetype, _ = mimetypes.guess_type(file_path)
+ if mimetype:
+ extra_args["ContentType"] = mimetype
+
s3_client.upload_file(
Filename=file_path,
Bucket=self.bucket,
Key=upload_key,
- ExtraArgs=self.s3_args,
+ ExtraArgs=extra_args,
)
def on_any_event(self, event: events.FileSystemEvent):