tus / tusd

Reference server implementation in Go of tus: the open protocol for resumable file uploads
https://tus.github.io/tusd
MIT License
3.05k stars 475 forks source link

Store the Mimetype on storage backends supporting it #1016

Open meidlinga opened 1 year ago

meidlinga commented 1 year ago

Question I would like to include the uploaded files mime type in the upload meta data. Then I would like to store this information along the uploaded file on Azure storage. On a quick glance over the code, I could not find this feature. Would this currently be possible in any way?

Setup details Please provide following details, if applicable to your situation:

Acconut commented 11 months ago

A similar question also appeared for S3 in https://github.com/tus/tusd/issues/978. I think it would be worth adding this to storages, which provide some mechanism for saving the file name and file type in a dedicated manner. Does Azure have such a functionality?

meidlinga commented 11 months ago

Yes, Azure supports it by adding a specific header in the upload request. It is x-ms-blob-content-type, documented here: https://learn.microsoft.com/en-us/rest/api/storageservices/put-blob?tabs=azure-ad#request-headers-all-blob-types

Acconut commented 11 months ago

That's good to know. It is also very similar to the Content-Type header that is used for AWS S3 to set the file type for an object: https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateMultipartUpload.html#API_CreateMultipartUpload_RequestSyntax

It should not be too hard to set those two values when creating an upload. tusd currently inspects the filetype meta data entry and sets Content-Disposition accordingly when a user downloads a file via tusd. We can also read this value and pass it to Azure, S3 etc.

Acconut commented 2 weeks ago

It would be great if tusd could set Content-Type, Content-Encoding, and Content-Disposition for storages that support it.