Hi, I want to send file in the response, I found it''s possible with render method: def get_file render :file => path, :content_type => "application/x-unknown" end. But there is one problem, the default name of that file in system dialog is the method name. Is it possible to set default file name? Greets. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Zirael wrote:> Hi, > I want to send file in the response, > I found it''s possible with render method: > def get_file > render :file => path, :content_type => "application/x-unknown" > end. > > But there is one problem, > the default name of that file in system dialog is the method name. > > Is it possible to set default file name? > > Greets....ever look into the FileUtils / File classes? -- 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 -~----------~----~----~----~------~----~------~--~---
Zirael wrote:> Hi, > I want to send file in the response, > I found it''s possible with render method: > def get_file > render :file => path, :content_type => "application/x-unknown" > end. > > But there is one problem, > the default name of that file in system dialog is the method name. > > Is it possible to set default file name? > > Greets.The file name is the last path step of the url... so put a complete url for that download in routes and map it to your get_file action... something like: map.connect ''/something/myfilename.xxx'', :controller => ''mycontroller'', :action => ''get_file'' Note that you may also need to set the Content-Disposition header to Attachment to get a file save dialog on some browsers... depending on the content-type I suppose. b --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---