Skip to content

Commit f1ef978

Browse files
committed
Support s3-file-field-client 1.0.0
1 parent 9e5ac9a commit f1ef978

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

isic_cli/cli/accession.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import mimetypes
23
from pathlib import Path
34
import sys
45

@@ -41,10 +42,19 @@ def upload(
4142
s3ff_client = S3FileFieldClient(f"{DOMAINS[ctx.env]}/api/v2/s3-upload/", ctx.session)
4243

4344
with accession.open("rb") as file_stream:
45+
content_type = mimetypes.guess_type(accession.name)[0]
46+
47+
if content_type is None:
48+
click.secho(
49+
f"Unable to determine content type for {accession.name}.", fg="red", err=True
50+
)
51+
sys.exit(1)
52+
4453
field_value = s3ff_client.upload_file(
45-
file_stream,
46-
accession.name,
47-
"ingest.Accession.original_blob",
54+
file_stream=file_stream,
55+
file_name=accession.name,
56+
file_content_type=content_type,
57+
field_id="ingest.Accession.original_blob",
4858
)
4959

5060
try:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
install_requires=[
3939
# we use the path_type=Path feature from click which was added in Click 8
4040
"click>=8",
41-
"django-s3-file-field-client",
41+
"django-s3-file-field-client>=1.0.0",
4242
# We expect girder-cli-oauth-client to drop oob support in the future
4343
"girder-cli-oauth-client<1.0.0",
4444
"humanize",

0 commit comments

Comments
 (0)