Hi, I am using send_file to allow users to download files from my website, please see code beloe: def download_document send_file("#{RAILS_ROOT}/public/test_form.pdf", :filename => "test.pdf", :type => ''application/pdf'', :disposition => ''attachment'', :streaming => ''true'', :buffer_size => ''4096'') end If i leave disposition => "attachment" i get the following error when trying to open the document: "Adobe Reader could not open the file type ....because it is either not a supported file type or because the file has become damaged...." Or if i change disposition => "inline" i get the following error message: File does not begin with ''%PDF-'' " Whats that all about??? I have the mime types set up correctly. Can anyone help me? JB -- 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 -~----------~----~----~----~------~----~------~--~---
This is the error from the log: TypeError (can''t convert String into Integer): /vendor/rails/actionpack/lib/action_controller/streaming.rb:75:in `sysread'' /vendor/rails/actionpack/lib/action_controller/streaming.rb:75:in `send_file'' /vendor/rails/actionpack/lib/action_controller/streaming.rb:71:in `open'' /vendor/rails/actionpack/lib/action_controller/streaming.rb:71:in `send_file'' /vendor/rails/actionpack/lib/action_controller/cgi_process.rb:183:in `call'' /vendor/rails/actionpack/lib/action_controller/cgi_process.rb:183:in `out It says it is trying to open test-2.pdf where is the -2 coming from?? -- 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 -~----------~----~----~----~------~----~------~--~---
> -----Original Message----- > From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of John Butler > Sent: Monday, April 23, 2007 7:53 AM > To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > Subject: [Rails] send_file pdf problem > > > Hi, > > I am using send_file to allow users to download files from my > website, please see code beloe: > > def download_document > send_file("#{RAILS_ROOT}/public/test_form.pdf", > :filename => "test.pdf", > :type => ''application/pdf'', > :disposition => ''attachment'', > :streaming => ''true'', > :buffer_size => ''4096'') > endHello, Which webserver? I spent quite a lot of time on this issue last year. I finally installed Apache 1.3.36, 2.0.48, 2.0.49, 2.0.58, and 2.2.2 from source, the installed Suse 2.0.48, along with lighttpd 1.4.11 and tested them all. As I recall, the problem stemmed mostly from the 2.0.48 distributed by Suse, and lighty. Also, the user had to have been using IE6, and the Acrobat Reader setting had to be to open the PDF in the same window as Explorer. Here is the lighty config file fix: $HTTP["url"] =~ "\.pdf$" { server.range-requests = "disable" } Which disallows range requests. The drawback is that the user will have to download the complete PDF file before they can view it, but it does eliminate the problem. I think there is more relevant data here: http://www.samspublishing.com/articles/article.asp?p=26698&rl=1 http://www.squid-cache.org/mail-archive/squid-dev/199801/0006.html Regards, Rich Duzenbury --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks Rich, this has me on the right track now. -- 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 -~----------~----~----~----~------~----~------~--~---
For me it works fine for code: file_path=c:/pdfs/file.pdf send_file(file_path, :filename => File.basename(file_path), :type => ''application/pdf'', :disposition => ''inline'', :streaming => ''true'', :buffer_size => 4096) <-- I changed that. But in fact I''m still in development stage and I haven''t tried it on Apache server. On 23 Kwi, 21:56, John Butler <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> This is the error from the log: > > TypeError (can''t convert String into Integer): > /vendor/rails/actionpack/lib/action_controller/streaming.rb:75:in > `sysread'' > /vendor/rails/actionpack/lib/action_controller/streaming.rb:75:in > `send_file'' > /vendor/rails/actionpack/lib/action_controller/streaming.rb:71:in > `open'' > /vendor/rails/actionpack/lib/action_controller/streaming.rb:71:in > `send_file'' > /vendor/rails/actionpack/lib/action_controller/cgi_process.rb:183:in > `call'' > /vendor/rails/actionpack/lib/action_controller/cgi_process.rb:183:in > `out > > It says it is trying to open test-2.pdf where is the -2 coming from?? > > -- > 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 -~----------~----~----~----~------~----~------~--~---