I"m aware of:
require ‘open-uri’
zipFile = open(URL).read
but this pulls back a string… I need to pull back a zip file
(binary).
Any ideas?
thanks,
phil
I"m aware of:
require ‘open-uri’
zipFile = open(URL).read
but this pulls back a string… I need to pull back a zip file
(binary).
Any ideas?
thanks,
phil
[email protected] wrote:
I"m aware of:
require ‘open-uri’
zipFile = open(URL).readbut this pulls back a string… I need to pull back a zip file
(binary).Any ideas?
Well since you are trying to unzip a ZIP file, I suggest you read about
the
Zlib::Inflate class in your documentation.
Start here:
http://www.ruby-doc.org/core/classes/Zlib/Inflate.html
The above page shows this example:
def inflate(string)
zstream = Zlib::Inflate.new
buf = zstream.inflate(string)
zstream.finish
zstream.close
buf
end
Isn’t Zlib for gzip? I’m trying to access a zip file.
To use ruby Zip for this, but I have a string, not a binary form the
require ‘open-uri’
zipFile = open(URL).read
code…
not sure how to proceed.
thanks,
phil
On 11/16/06, [email protected] [email protected] wrote:
thanks,
The string you have is the content of the zip file. To make it a file
just write it to a file.
File.open(NAME, ‘wb’) {|f| f.write string}
You may want to try rubyzip.sf.net
I’m not sure but I think gzip and zip files use the same compression.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs