views:

264

answers:

1

Hi all,

I'm working on my first ORM project and am using Mechanize. Here's the situation:

I'm downloading a zip file from my website into a Mechanize::File object. Inside the zip is a file buried three folders deep (folder_1/folder_2/file.txt). I'd like to pull file.txt out of the zip file and return that instead of the zip file itself.

My first thought was to use zip/zipfilesystem. I can do this fine if I save the file to the disk first and use Zip::ZipFile.open(src) but can anyone tell me how/if it is possible to send it over straight from the Mechanize::File.body.

My gut says this has to be possible and I'm just missing something basic. I tried...

zipfile = Mechanize::File.body
Zip::ZipFile.open(zipfile)

...but from what I can tell Zip::ZipFile is only set up to locate a source from a filesystem.

Any direction would be very appreciated and let me know if there are any questions

Thanks in advance Rob

+1  A: 

It seems what you want to do is not possible with rubyzip. From rubyzip library's TODO file:

  • SUggestion: ZipInputStream/ZipOutputStream should accept an IO object in addition to a filename.
mtyaka