rubyzip

How do I get a zipped file's content using the rubyzip library?

I'm trying to extract an uploaded zip file and store its contents in the database, one entry per file. The rubyzip library has nearly no useful documentation. There is an assets table that has key :string (file name) and data :binary (file contents). I'm using the rubyzip library, and have made it as far as this: Zip::ZipFile.open(@f...

How to unzip password protected file via Ruby

I'd like to unzip an encrypted/password protected file via a Ruby script without dropping down to a system call. I currently use the rubyzip library to unzip files but don't see an option for working with encrypted files. Anyone know of some code or a library that will do this? ...

Opening a multipart/form-data ZIP file with rubyzip

I want to extract the files within a ZIP file I uploaded to my Rails app. The files within the ZIP file are going to be stored in the database. I want to open the ZIP file in my action, without first having to save the file to a folder - I want to open the multipart/form-data stream with rubyzip. It looks like rubyzip's ZipFile.open on...

How can I copy a directory inside a zip archive to a second zip archive using rubyzip?

I have a .zip archive containing several directories. Using the rubyzip gem I would like to reach into the .zip archive, copy a specified directory (and its contents) and move the directory into a second .zip archive. Ideally I would not have to extract the contents of the first .zip archive, then re-zip them into a second archive. I'...

Read file comments from a zip file in Ruby

I am doing Python challenge in Ruby. I need to read the file contents and comments from a Zip file. The content is no problem with the RubyZip gem but I am unable to get the comments out. Any ideas? ...

How to close a ZipFile

I'm passing a dynamic zip file location to a def from a database. I want to unzip the file to a temp location, extract the xml report file inside, apply an xslt stylesheet, copy it as an rhtml to a view directory for rendering, and delete the temp extracted xml file. The functionality is working fine (the rhtml file is overwritten each t...

How do I find a specific entry inside a zipped directory using the rubyzip gem?

I have a zip file named test.zip which contains a directory named invoice. Inside the invoice directory there are documents each with different names. I would like to find a specific document named summary.txt which is inside the invoice directory. I am able to get a handle to test.zip using the following: zip = Zip::ZipFile.open("/p...

Using rubyzip to add files and nested directories to a zipoutputstream

Hi, I'm struggling with getting rubyzip to append directories to a zipoutputstream. (I want the output stream so I can send it from a rails controller). My code follows this example: http://info.michael-simons.eu/2008/01/21/using-rubyzip-to-create-zip-files-on-the-fly/ When modified to include directories in the list of files to add I...

Set compression level when generating a ZIP file using RubyZip

Hi, I have a Ruby program that zips a directory tree of XML files using the rubyzip gem. My problem is that the file is starting to be heavy and I would like to increase the compression level, since compression time is not an issue. I could not find in the rubyzip documentation a way to specify the compression level for the created ZIP...

Rubyzip - possible to set extraction folder?

Hi. My problem is that I need to set the root extraction folder for a zip-file I`m generating by using Rubyzip. The zip-file will be opened in MS windows as an zelf-extractable. Is this option available in Rubyzip? Or is this a value that is stored in the windows registry and used by the integrated zip-functionality in windows? ~ Tord ...

RubyZip turning JPGs into "not JPGs, starts with 0x89"

Hi, I'm using RubyZip to compress a set of images (uploaded using Paperclip) and allow the user to download them in one file, and all works fine until I come to open an image. It wont display, and trying on Ubuntu I get the error message: "Error interpreting JPEG image file (Not a JPEG file: starts with 0x89..." So the user is downlo...

How to edit docx with nokogiri and rubyzip

I'm using a combination of rubyzip and nokogiri to edit a .docx file. I'm using rubyzip to unzip the .docx file and then using nokogiri to parse and change the body of the word/document.xml file but ever time I close rubyzip at the end it corrupts the file and I can't open it or repair it. I unzip the .docx file on desktop and check th...