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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

bjarkigud
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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/377623dd-ffa5-4c54-a3ec-c8cace081ef0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Hassan Schroeder-2
On Fri, Jan 12, 2018 at 5:01 AM,  <[hidden email]> 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 ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yCAXBKFviSmfGtO7D4u%3DBaDt-QYNXvrA-7ygaNMkgWoWw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.