hi guys, I have to create a download link.As a newbie in ruby i googled for it and found the way for my problem. def attachment send_file(''/images/header.gif'', :filename => ''My Filename!'', :type => ''image/gif'', :disposition => ''attachment'', :streaming => ''true'', :buffer_size => ''4096'') end but it show file download error: Cannot read file /images/header.gif My file location /images/header.gif what is the wrong? please mention a better way if any. please help me. Amin -- 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 -~----------~----~----~----~------~----~------~--~---
Ruhul Amin wrote:> hi guys, > I have to create a download link.As a newbie in ruby i googled for it > and > found the way for my problem. > > def attachment > send_file(''/images/header.gif'', > :filename => ''My Filename!'', > :type => ''image/gif'', > :disposition => ''attachment'', > :streaming => ''true'', > :buffer_size => ''4096'') > end > > but it show file download error: Cannot read file /images/header.gif > My file location /images/header.gif > what is the wrong? > please mention a better way if any. > please help me. > > Aminsend_file takes the full path to a file that is local on the webserver, not a url. It reads the data in that file and sends it back out to the browser. So what you most likely need is: send_file("#{RAILS_ROOT}/public/images/header.gif", ...) -- 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 -~----------~----~----~----~------~----~------~--~---
Alex Wayne wrote:> > send_file takes the full path to a file that is local on the webserver, > not a url. It reads the data in that file and sends it back out to the > browser. So what you most likely need is: > > send_file("#{RAILS_ROOT}/public/images/header.gif", ...)Thx for ur help. -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Luigi wrote:> Hi, > do you know anyway to read a file with url? > > Thank you > > LuigiDear Luigi, Use a library. Net::HTTP (in ''net/http'') for http://... , Net::FTP (in ''net/ftp'') for ftp://..., etc You have examples in the documentation of these libraries. If not solved... please write agin. Tuhin -- 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 -~----------~----~----~----~------~----~------~--~---