UNCLASSIFIED
Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Ironbank Tools
ironbank-plugins-pipeline
Commits
fc20591b
Commit
fc20591b
authored
Dec 09, 2020
by
David Freeman
Browse files
get file mime-type for S3 upload
parent
1cc948be
Pipeline
#97422
passed with stages
in 1 minute and 7 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
1 deletion
+9
-1
stages/publish/s3_upload.py
stages/publish/s3_upload.py
+9
-1
No files found.
stages/publish/s3_upload.py
View file @
fc20591b
...
...
@@ -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
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment