From: Markus Date: 2004-10-09T02:43:43+09:00 Subject: Re: open-uri and ftp problem You could just modify the definition of FTP.getbinaryfile (either by modifying the source or overriding it in your code) like so: def getbinaryfile(remotefile, localfile = File.basename(remotefile), blocksize = DEFAULT_BLOCKSIZE, &block) # :yield: data if @resume rest_offset = File.size?(localfile) f = open(localfile, "a") elsif localfile == '/dev/nul' or localfile == nil rest_offset = nil f = nil else rest_offset = nil f = open(localfile, "w") end begin f.binmode if f retrbinary("RETR " + remotefile, blocksize, rest_offset) do |data| f.write(data) if f yield(data) if block end ensure f.close if f end end And that should do what you want. If this is something you will be using for a while, I'd suggest negotiating/propagating the change to the appropriate maintainers, so you don't have to revisit the fix every time you upgrade. -- Markus On Fri, 2004-10-08 at 10:10, Henrik Horneber wrote: > Tanaka Akira wrote: > > > > > I think Net::FTP#getbinaryfile should accept nil as the localfile > > argument. > > > > If so, open-uri can avoid /dev/null. > > Hi! > > Thanks for your reply! > > Unfortunately, Net::FTP#getbinaryfile does not accept nil, as far as I > understand the source, it passes the parameter to open, and dies with > > H:/ruby/ruby_install/ruby/lib/ruby/1.8/open-uri.rb:87:in > `open_uri_original_open': cannot convert nil into String (TypeError) > > When I change > > ftp.getbinaryfile(self.path, '/dev/null', Net::FTP::DEFAULT_BLOCKSIZE) > {|str| > > to > > ftp.getbinaryfile(self.path) {|str| > > in open-uri.rb, it only falls back to Net::FTP#getbinaryfile's default > value, which simply is the basename of the remote file, so that I end up > with the file on my hard drive. (This sounds strange if you don't know > the context, but this gets called from open("ftp://") with a block, so I > want to handle the data myself without temporary storage on disk) . > > I'm stuck. Would this not be a problem if I were using the cygwin build, > because there might exist some fake /dev/null? > > regards, > Henrik >