UNCLASSIFIED

Commit fc20591b authored by David Freeman's avatar David Freeman
Browse files

get file mime-type for S3 upload

parent 1cc948be
Pipeline #97422 passed with stages
in 1 minute and 7 seconds
......@@ -5,6 +5,7 @@ import argparse
import datetime
from botocore.exceptions import ClientError
import logging
import mimetypes
def upload_file(file_name, bucket, object_name=None):
......@@ -19,8 +20,15 @@ def upload_file(file_name, bucket, object_name=None):
access_key = os.environ["S3_ACCESS_KEY"]
secret_key = os.environ["S3_SECRET_KEY"]
filetype = mimetypes.guess_type(file_name)
if not filetype[0]:
mimetype = "application/octet-stream"
else:
mimetype = filetype[0]
# TODO: Add signature
extra_args = {"ContentType": "application/octet-stream", "ACL": "private"}
extra_args = {"ContentType": mimetype, "ACL": "private"}
# If S3 object_name was not specified, use file_name
if object_name is None:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment