File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 11import json
2+ import mimetypes
23from pathlib import Path
34import 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 :
Original file line number Diff line number Diff line change 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" ,
You can’t perform that action at this time.
0 commit comments