From: Joel VanderWerf Date: 2006-05-30T08:03:34+09:00 Subject: Re: Saving a PDF locally Yochen Gutmann wrote: > Joel VanderWerf wrote: >> Use "wb" instead of "w". On windows, this treats the data as binary >> instead of lines of text that should be terminated with cr-lf. > well, although I am working on OSX (forgot to mention), I tried your > hint but that did not work(like expected). Hm.. Any other idea? > > -Yochen > Sorry! I jumped to conclusions about the problem. The following works for me on linux. Can't make any predictions about OSX, tho'. require 'open-uri' open("http://path.berkeley.edu/~vjoel/redshift/ruby-sdforum.pdf"){|u| targetFile = File.new("test.pdf","w") u.each_byte {|ch| targetFile.putc ch } } Why are you doing it a byte at a time? This seems to run much faster for me: require 'open-uri' open("http://path.berkeley.edu/~vjoel/redshift/ruby-sdforum.pdf") do |u| targetFile = File.new("test.pdf","w") loop do dat = u.read(1000) break unless dat targetFile.write dat end end -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407