Override how the content_type gets set on ActionDispatch::Http::UploadedFile?

45 views
Skip to first unread message

bjar...@gmail.com

unread,
Jan 12, 2018, 9:51:25 AM1/12/18
to Ruby on Rails: Talk
Hi,

I have extension-less DICOM files that I need to determine the proper MIME type on when uploaded.

file  --b  --mime-type  MyFile

reports the files as application/dicom so I know they are valid but when uploaded through Rails they get the type 'applcation/octet-stream'. Is there an easy way to change this behaviour preferably without monkey patching? Could this be done through Rack middleware to provide a general solution?

I am running version 5.2.0.beta2 on Ruby 2.5.0

/bjarki

Hassan Schroeder

unread,
Jan 12, 2018, 11:45:13 AM1/12/18
to rubyonrails-talk
On Fri, Jan 12, 2018 at 5:01 AM, <bjar...@gmail.com> wrote:

> I have extension-less DICOM files that I need to determine the proper MIME
> type on when uploaded.
>
> file --b --mime-type MyFile
>
> reports the files as application/dicom so I know they are valid but when
> uploaded through Rails they get the type 'applcation/octet-stream'.

What is doing the "uploading"? If it's through a browser/form, I'd
imagine the browser is setting the Content-Type header.

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote
Reply all
Reply to author
Forward
0 new messages