Hello,
I wonder if you could tell me how to make the navigator force the
download.
In PHP it works like this:
$downloadfile="fichero.gpx";
header("Content-disposition: attachment; filename=$downloadfile");
header("Content-Type: application/force-download");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".strlen($myGPXCode));
header("Pragma: no-cache");
header("Expires: 0");
echo $myGPXCode;
What would be a similar code to the above for Ruby on Rails?
Thank you.
--
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
-~----------~----~----~----~------~----~------~--~---
On 11/6/07, David Bravo <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hello, > > > > I wonder if you could tell me how to make the navigator force the > download. > > In PHP it works like this: > > > $downloadfile="fichero.gpx"; > header("Content-disposition: attachment; filename=$downloadfile"); > header("Content-Type: application/force-download"); > header("Content-Transfer-Encoding: binary"); > header("Content-Length: ".strlen($myGPXCode)); > header("Pragma: no-cache"); > header("Expires: 0"); > echo $myGPXCode; > > What would be a similar code to the above for Ruby on Rails?send_data myGPXCode, :filename => ''fichero.gpx'' You can''t actually "force" the browser to do anything, but this gives the proper "suggestions" to the browser to trigger the "save as" dialog... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You are looking for send_file: http://api.rubyonrails.org/classes/ActionController/Streaming.html#M000092 -Bill Bob Showalter wrote:> On 11/6/07, David Bravo <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > >> Hello, >> >> >> >> I wonder if you could tell me how to make the navigator force the >> download. >> >> In PHP it works like this: >> >> >> $downloadfile="fichero.gpx"; >> header("Content-disposition: attachment; filename=$downloadfile"); >> header("Content-Type: application/force-download"); >> header("Content-Transfer-Encoding: binary"); >> header("Content-Length: ".strlen($myGPXCode)); >> header("Pragma: no-cache"); >> header("Expires: 0"); >> echo $myGPXCode; >> >> What would be a similar code to the above for Ruby on Rails? >> > > send_data myGPXCode, :filename => ''fichero.gpx'' > > You can''t actually "force" the browser to do anything, but this gives > the proper "suggestions" to the browser to trigger the "save as" > dialog... > > > >-- Sincerely, William Pratt --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---