remotipart icon indicating copy to clipboard operation
remotipart copied to clipboard

Rails 6 / 6.1 deprecation warning for #content_type

Open shepmaster opened this issue 5 years ago • 1 comments

DEPRECATION WARNING: Rails 6.1 will return Content-Type header without modification. If you want just the MIME type, please use #media_type instead.

gems/remotipart-1.4.4/lib/remotipart/render_overrides.rb:37:in `treat_render_for_remotipart'
gems/remotipart-1.4.4/lib/remotipart/render_overrides.rb:23:in `render'

https://github.com/JangoSteve/remotipart/blob/v1.4.4/lib/remotipart/render_overrides.rb#L37

shepmaster avatar Feb 11 '20 18:02 shepmaster

I did some basic investigation on that and came to the conclusion that the deprecation warning can be ignored.

After setting the following configuration, file uploads continued to work:

Rails.application.config.action_dispatch.return_only_media_type_on_content_type = false
ActionDispatch::Response.return_only_media_type_on_content_type = false

I believe the reason for this can be found in jquery.iframe-transport.js: https://github.com/JangoSteve/remotipart/blob/master/vendor/assets/javascripts/jquery.iframe-transport.js#L222 The content_type from the textarea is simply passed to jQuery as Content-Type. jQuery seems to be able to handle any extra ; charset=utf-8 information.

lacco avatar Dec 03 '21 08:12 lacco