Skip to content

Commit

Permalink
Merge pull request #64 from ImageMarkup/support-s3ff-1
Browse files Browse the repository at this point in the history
  • Loading branch information
danlamanna authored Oct 18, 2023
2 parents 9e5ac9a + f1ef978 commit 8700605
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions isic_cli/cli/accession.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import mimetypes
from pathlib import Path
import sys

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

with accession.open("rb") as file_stream:
content_type = mimetypes.guess_type(accession.name)[0]

if content_type is None:
click.secho(
f"Unable to determine content type for {accession.name}.", fg="red", err=True
)
sys.exit(1)

field_value = s3ff_client.upload_file(
file_stream,
accession.name,
"ingest.Accession.original_blob",
file_stream=file_stream,
file_name=accession.name,
file_content_type=content_type,
field_id="ingest.Accession.original_blob",
)

try:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
install_requires=[
# we use the path_type=Path feature from click which was added in Click 8
"click>=8",
"django-s3-file-field-client",
"django-s3-file-field-client>=1.0.0",
# We expect girder-cli-oauth-client to drop oob support in the future
"girder-cli-oauth-client<1.0.0",
"humanize",
Expand Down

0 comments on commit 8700605

Please sign in to comment.