Topic: send_file not opening dialog

Hello,

We are using JRuby 1.5.1/ruby 1.8.7/Rails 2.3.8 with a GWT front end.

I'm having an issue when attempting to send a server side .csv file to the user using rails send_file.

my code is:

send_file(path_to_file, type=>'text/csv')

While this is returning fine with an http status of 200, the client side save as dialog is never opening for the user to receive the file. Any ideas why this isn't working?

Re: send_file not opening dialog

I forgot to mention we are using the glassfishv3 gem as our app server

Re: send_file not opening dialog

Alright since we cant get send_file to work apparently, I am trying to use a work around by passing the filepath back to GWT in a response header then calling a javascript window to open for a download.

The problem is that rails keeps coming back with a not valid route. I can't figure out how to send the get request to the folder. For now I've put the generated csv file in the public folder.

If I use a static name for the file and put a route in routes.rb like this:

map.connect 'public/temp.csv', :controller=>'filters', :action=>'download'

I can correctly download the file. Problem is we do not want a static file name and changing the file name breaks this approach. I am relatively new to rails, I have read teh docs on routing however all they do is route to controllers. I need to route to a folder/file not a controller.

If the above is not possible in rails, I need information on how to pass the file to the  user in a method call within the controller as I have no idea how to do this except send_file which doesnt work.

The routing error I'm getting is:

No route matches "/path/to/public/temp.csv" with {:method=> :get}

where /path/to/public is the path to my public folder. Is there an easy way to assign a route for a dynamically generated file name? As long as I always have the file created in the public folder?

Anyone?

Last edited by ryepie (2012-06-01 10:17:26)