hi i am my application i want a some link in which when a user click a file from my server get downloaded to user site. please reply urgent. -- 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 -~----------~----~----~----~------~----~------~--~---
that''s all you would need: link_to(''download file'', "/docs/test.pdf") assuming a file test.pdf exists in rails_root/public/docs -- 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 -~----------~----~----~----~------~----~------~--~---
Thorsten Mueller wrote:> that''s all you would need: > > link_to(''download file'', "/docs/test.pdf") > > assuming a file test.pdf exists in rails_root/public/docsfrom rhtml i want a link when user click on that link it ask where to download and if file is in another directory how to specify path -- 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 -~----------~----~----~----~------~----~------~--~---
The file(s) that the user would download should reside somewhere within RAILS_ROOT/public or a subdirectory thereof. If the file was RAILS_ROOT/public/files/myfile.pdf, you would use the link_to method like this: <%= link_to "linked text", "/files/myfile.pdf" %> This would create the following HTML, or something very close: <a href="/files/myfile.pdf">linked text</a> Generally, Rails looks for static files relative to public/, so when a request for "/files/myfile.pdf" comes in, it will look for "RAILS_ROOT/ public/files/myfile.pdf". So, that''s how to create the link and how to specify the path. Whether or not the user will be asked to download the file will depend upon the file type and the user''s browser preferences. When I access a PDF, my browser automatically displays it using an Acrobat Reader plugin. If I request an unknown file type, it will ask me if I''d like to download it. I don''t think that there is a way to make sure that the file is literally downloaded and saved on the user''s computer (somewhere other than /tmp or similar) without changing the extension, and that is not advisable. -Kyle On May 6, 8:16 am, Sunny Bogawat <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Thorsten Mueller wrote: > > that''s all you would need: > > > link_to(''download file'', "/docs/test.pdf") > > > assuming a file test.pdf exists in rails_root/public/docs > > from rhtml i want a link when user click on that link it ask where to > download and if file is in another directory how to specify path > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Tue, May 6, 2008 at 3:07 PM, Kyle <kyle.rabe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> ...... I don''t think that there is a way to make sure that > the file is literally downloaded and saved on the user''s computer > (somewhere other than /tmp or similar) without changing the extension,Sure, handle the download yourself, setting the following headers: Content-disposition: attachment; filename=$whatever_file Content-length: $whatever_file_size :: then the browser will prompt the user for what to do with it. HTH, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 7 May 2008, at 00:36, Hassan Schroeder wrote:> > On Tue, May 6, 2008 at 3:07 PM, Kyle <kyle.rabe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> ...... I don''t think that there is a way to make sure that >> the file is literally downloaded and saved on the user''s computer >> (somewhere other than /tmp or similar) without changing the >> extension, > > Sure, handle the download yourself, setting the following headers: > > Content-disposition: attachment; filename=$whatever_file > Content-length: $whatever_file_size >that''s what send_file/send_data do. You still can''t be 100% what the users browser will do though. (sometimes peopleseem to set the mime tpe to application/force-download in order to prevent the browser from thinking that it knows how to display the file. Fred> :: then the browser will prompt the user for what to do with it. > > HTH, > -- > Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > >--~--~---------~--~----~------------~-------~--~----~ 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 Tue, May 6, 2008 at 4:44 PM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Content-disposition: attachment; filename=$whatever_file > > Content-length: $whatever_file_size > > > that''s what send_file/send_data do.Ah, thanks for the tip -- I''m used to doing this in Java servlets, but haven''t had a need to do it for a Rails site yet. -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks for the correction. I haven''t needed to do this before. -Kyle On May 6, 6:52 pm, "Hassan Schroeder" <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Tue, May 6, 2008 at 4:44 PM, Frederick Cheung > > <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Content-disposition: attachment; filename=$whatever_file > > > Content-length: $whatever_file_size > > > that''s what send_file/send_data do. > > Ah, thanks for the tip -- I''m used to doing this in Java servlets, but > haven''t had a need to do it for a Rails site yet. > > -- > Hassan Schroeder ------------------------ hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hassan Schroeder wrote:> On Tue, May 6, 2008 at 4:44 PM, Frederick Cheung > <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > Content-disposition: attachment; filename=$whatever_file >> > Content-length: $whatever_file_size >> > >> that''s what send_file/send_data do. > > Ah, thanks for the tip -- I''m used to doing this in Java servlets, but > haven''t had a need to do it for a Rails site yet. > > -- > Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.orgHi, now my code working correctly for IE but in Mozilla it opens csv file directly in browser so how it avoid so pop up come and ask for saving in Mozilla. -- 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 -~----------~----~----~----~------~----~------~--~---
http://teapoci.blogspot.com/2008/05/linktofile-call-file-from-rhtml-or.html reinhart -- 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 -~----------~----~----~----~------~----~------~--~---
I''ve used the following to render out csv: send_file ''my_csv_file'', :content_type=>''text/csv'' On May 20, 4:06 am, Rails Terrorist <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> http://teapoci.blogspot.com/2008/05/linktofile-call-file-from-rhtml-o... > > reinhart > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
AndyV wrote:> I''ve used the following to render out csv: > > send_file ''my_csv_file'', :content_type=>''text/csv'' > > On May 20, 4:06 am, Rails Terrorist <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>where this code used? and how used?please give clear description. -- 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 -~----------~----~----~----~------~----~------~--~---
Sorry, I thought that would be obvious enough. It''s in a controller method that''s set up to handle the request for the csv file (as only a controller method could). On May 21, 1:02 am, Sunny Bogawat <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> AndyV wrote: > > I''ve used the following to render out csv: > > > send_file ''my_csv_file'', :content_type=>''text/csv'' > > > On May 20, 4:06 am, Rails Terrorist <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > where this code used? and how used?please give clear description. > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---