Skip to content

Commit

Permalink
Fixes #2 based on boto/boto3#548
Browse files Browse the repository at this point in the history
  • Loading branch information
gricey432 committed Sep 30, 2020
1 parent 7029b01 commit d3f283a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .idea/sharpei.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion sharpei/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from os import path
from typing import Union
import logging
import mimetypes

from watchdog import events
import boto3
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit d3f283a

Please sign in to comment.