need to fetch a zip file from url and unzip it

P

phil.swenson

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
 
P

phil.swenson

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
code...

not sure how to proceed.

thanks,

phil
 
J

Jan Svitok

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

code...

not sure how to proceed.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top