tator
tator copied to clipboard
Allow setting the content-type when uploading to S3/S3-compatible storage
When files are uploaded to S3, the associated content-type appears to be dependent on the S3 storage environment (e.g. it may be plain/text or binary/octet-stream). Tator File object downloads are not broken, but this makes it prohibitive in the scenario of dynamically loading JavaScript due to the strict MIME type checking. To enable this capability, the content-type should be a parameter that can be set as part of the UploadInfo endpoint.
Seems like the offending code is here: https://github.com/cvisionai/tator/blob/47c51d371a6bbcb816876264062c24279c0ce0e3/main/store.py#L352-L369
The underlying API call supports specifying content type, unclear what boto3/object storage is doing when not specified, I'd guess assuming binary in at least some permutations. https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Client.create_multipart_upload
Seems like using mimetypes prior to the boto3 call is the way to go.