Platform = Linux and Mongrel I''m using send_file to send images from a controller. like this: send_file( @content.location, :disposition => ''inline'', :type => File.mime_type?(@content.location)) # mime_type? courtesy of mimetype_fu This is called for in an ordinary <img> tag. It all works perfectly except for one minor hitch which is driving me mad. If you right click on the image in IE7 and choose "Save Image As..." the file save dialog always defaults the filename to "untitled.bmp". Other browsers always get the correct file name (usually something like "61.png" or "18.jpg") If I copy the file into the corresponding path under RAILS_ROOT/public then IE7 will get the filename correct - as will all browsers. Interestingly if you do save the file as untitled.bmp it''s a perfectly good bmp file. The HTTP headers set by mongrel differ substantially from the ones set by send_file. Using send_file gives: Status=OK - 200 Date=Tue, 16 Sep 2008 18:16:59 GMT Server=Mongrel 1.1.4 Vary=Host Status=200 OK X-Runtime=0.01416 Content-Transfer-Encoding=binary Cache-Control=private Content-Disposition=inline; filename="16.jpg" Content-Type=image/jpeg Content-Length=164553 X-Cache=MISS from www.sharehost.co.uk Keep-Alive=timeout=15, max=100 Connection=Keep-Alive Serving the file from the public area gives: Status=OK - 200 Date=Tue, 16 Sep 2008 18:17:09 GMT Vary=Host Etag="48cfb25c-65c2f-918190" Last-Modified=Tue, 16 Sep 2008 13:19:24 GMT Content-Type=image/jpeg Content-Length=416815 X-Cache=MISS from www.sharehost.co.uk Keep-Alive=timeout=15, max=99 Connection=Keep-Alive Anybody know what I can do about this? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mark Reginald James
2008-Sep-16 20:53 UTC
Re: send_file problem with IE7. Save Image as untitled.bmp
Noel Walters wrote:> I''m using send_file to send images from a controller. like this: > > send_file( @content.location, :disposition => ''inline'', :type => > File.mime_type?(@content.location)) # mime_type? courtesy of mimetype_fu > > This is called for in an ordinary <img> tag. > > It all works perfectly except for one minor hitch which is driving me > mad. > > If you right click on the image in IE7 and choose "Save Image As..." the > file save dialog always defaults the filename to "untitled.bmp".Try using send_file''s :filename option. -- Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Noel Walters
2008-Sep-16 21:20 UTC
Re: send_file problem with IE7. Save Image as untitled.bmp
Mark Reginald James wrote:> Noel Walters wrote: > >> If you right click on the image in IE7 and choose "Save Image As..." the >> file save dialog always defaults the filename to "untitled.bmp". > > Try using send_file''s :filename option. > > > -- > Rails Wheels - Find Plugins, List & Sell Plugins - > http://railswheels.comI already tried that but it makes no difference - the response headers are exactly the same. In fact in the one instance when explorer gets it right (when the file is served normally without using send_file) there is no content-disposition header and no mention of the filename in any of the other headers either. Thanks anyway! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Your other solution that should work is to set the header directly that IE is parsing, Content-Disposition. i.e.: headers[''Content-Disposition''] = "inline; filename=\"" + @filename + "\"" -Brady brady-vPvWGLPDSrsV+D8aMU/kSg@public.gmane.org On Sep 16, 12:28 pm, Noel Walters <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Platform = Linux and Mongrel > > I''m using send_file to send images from a controller. like this: > > send_file( @content.location, :disposition => ''inline'', :type => > File.mime_type?(@content.location)) # mime_type? courtesy of mimetype_fu > > This is called for in an ordinary <img> tag. > > It all works perfectly except for one minor hitch which is driving me > mad. > > If you right click on the image in IE7 and choose "Save Image As..." the > file save dialog always defaults the filename to "untitled.bmp". > > Other browsers always get the correct file name (usually something like > "61.png" or "18.jpg") > > If I copy the file into the corresponding path under RAILS_ROOT/public > then IE7 will get the filename correct - as will all browsers. > > Interestingly if you do save the file as untitled.bmp it''s a perfectly > good bmp file. > > The HTTP headers set by mongrel differ substantially from the ones set > by send_file. > > Using send_file gives: > > Status=OK - 200 > Date=Tue, 16 Sep 2008 18:16:59 GMT > Server=Mongrel 1.1.4 > Vary=Host > Status=200 OK > X-Runtime=0.01416 > Content-Transfer-Encoding=binary > Cache-Control=private > Content-Disposition=inline; filename="16.jpg" > Content-Type=image/jpeg > Content-Length=164553 > X-Cache=MISS fromwww.sharehost.co.uk > Keep-Alive=timeout=15, max=100 > Connection=Keep-Alive > > Serving the file from the public area gives: > > Status=OK - 200 > Date=Tue, 16 Sep 2008 18:17:09 GMT > Vary=Host > Etag="48cfb25c-65c2f-918190" > Last-Modified=Tue, 16 Sep 2008 13:19:24 GMT > Content-Type=image/jpeg > Content-Length=416815 > X-Cache=MISS fromwww.sharehost.co.uk > Keep-Alive=timeout=15, max=99 > Connection=Keep-Alive > > Anybody know what I can do about this? > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Noel Walters
2008-Sep-16 23:51 UTC
Re: send_file problem with IE7. Save Image as untitled.bmp
brady8 wrote:> Your other solution that should work is to set the header directly > that IE is parsing, Content-Disposition. > > i.e.: > > headers[''Content-Disposition''] = "inline; filename=\"" + @filename + > "\"" > > -Brady > brady-vPvWGLPDSrsV+D8aMU/kSg@public.gmane.org > > On Sep 16, 12:28�pm, Noel Walters <rails-mailing-l...@andreas-s.net>Thanks, but send_file already puts the correct Content-Disposition header in the response, but IE only seems to work properly when it''s missing - but there are other differences in the headers, so I can''t tell if that is significant or not. Here is the response header that you get when the server sends a file from a public folder. It works properly with all the browsers I''ve tried - Status=OK - 200 Date=Tue, 16 Sep 2008 18:17:09 GMT Vary=Host Etag="48cfb25c-65c2f-918190" Last-Modified=Tue, 16 Sep 2008 13:19:24 GMT Content-Type=image/jpeg Content-Length=416815 X-Cache=MISS from www.sharehost.co.uk Keep-Alive=timeout=15, max=99 Connection=Keep-Alive This is what send_file is producing. It doesn''t work properly with IE - Status=OK - 200 Date=Tue, 16 Sep 2008 18:16:59 GMT Server=Mongrel 1.1.4 Vary=Host Status=200 OK X-Runtime=0.01416 Content-Transfer-Encoding=binary Cache-Control=private Content-Disposition=inline; filename="16.jpg" Content-Type=image/jpeg Content-Length=164553 X-Cache=MISS from www.sharehost.co.uk Keep-Alive=timeout=15, max=100 Connection=Keep-Alive I did wonder if the doubled Status header is the source of the problem - but I''ve no idea how to get rid of it without abandoning the use of send_file. if there was a way to get send_file to produce a response like the first one I''d be quite happy. otherwise I''ll just have to put up with it - it''s not terribly serious just inconsistent. Maybe I could make the controller create a publicly accesible symlink to the file, do a redirect to the same controller/action and then delete the link again. I''ve been frigging about with this for 3 days now. Not feeling terribly Agile. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---