render file

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.

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