Questions tagged [rubyzip]

a ruby library for reading and writing zip files

rubyzip is a ruby library for reading and writing zip files.

Requirements - Ruby 1.9.2 or greater

There is more than one way to access or create a zip archive with rubyzip. The basic is modeled after the classes in java.util.zip from the Java SDK. This means there are classes such as Zip::ZipInputStream, Zip::ZipOutputStream and Zip::ZipFile. Zip::ZipInputStream provides a basic interface for iterating through the entries in a zip archive and reading from the entries in the same way as from a regular File or IO object. ZipOutputStream is the corresponding basic output facility. Zip::ZipFile provides a mean for accessing the archives central directory and provides means for accessing any entry without having to iterate through the archive. Unlike Java‘s java.util.zip.ZipFile rubyzip‘s Zip::ZipFile is mutable, which means it can be used to change zip files as well.

Another way to access a zip archive with rubyzip is to use rubyzip‘s Zip::ZipFileSystem API. Using this API files can be read from and written to the archive in much the same manner as ruby‘s built-in classes allows files to be read from and written to the file system.

rubyzip also features the zip/ziprequire.rb module which allows ruby to load ruby modules from zip archives.

Links

Related tag

136 questions
1
vote
0 answers

Rubyzip problems on Windows

I'm using Rubyzip to unzip files that are uploaded by the user. The file contains a bunch of images, which are unpacked and put into a folder. This works fine on a mac, but on windows it won't unpack the zip file. Here's the model I use: require…
Stefan Hagen
  • 658
  • 3
  • 11
  • 25
1
vote
3 answers

rubyzip and unicode characters in filenames

I am creating zip archive with rubyzip gem and Zip::ZipOutputStream class and have got a problem with unicode letters (cyrillic) - in archive they are presented as question marks like ????? ???? ??.doc. Does rubyzip support unicode?
fl00r
  • 82,987
  • 33
  • 217
  • 237
1
vote
2 answers

How to rename file and directory in a zip file using rubyzip

I'm trying to rename a file and a directory in a zip. I'd tried three different, all not working. What is the right command to do it? Below is the excerpt of my code: require 'zip/zip' ... def renaming_zip(zip_file) …
jmsia
  • 43
  • 1
  • 1
  • 4
1
vote
1 answer

Can't install RubyZip gem on OS X Lion with RVM

TL;DR: $ gem install rubyzip ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /Users/darth/.rvm/gems/ruby-1.9.2-p136/gems/rubyzip-0.9.4/README And now in detail. I'm not sure which information is relevant, so I'm just…
Jakub Arnold
  • 85,596
  • 89
  • 230
  • 327
1
vote
1 answer

rubyzip error undefined method 'join' for Zip::File:Class

following the documentation for rubyzip 2.3.2, I have this method: def zip_files(zip_file_name, files) Zip::File.open(zip_file_name, Zip::File::CREATE) do |zipfile| files.each do |filename| zipfile.add(filename, File.join('.', filename)) …
bradb
  • 11
  • 1
1
vote
0 answers

How to zip a list of blobs in ruby

I have a Rails 6 app. I'm using Rmagick (which wraps ImageMagick) to process several images. I need to zip them into a single file that will be get attached to a record a la active_storage. Here's the simplified code: # each item is an instance of…
emersonthis
  • 32,822
  • 59
  • 210
  • 375
1
vote
0 answers

RubyZip doesn't work well after updating zlib to v.1.2.12

I have updated zlib from 1.2.11 to 1.2.12. After this updating, RubyZip doesn't work well, The following code generates a zip file includeing a empty file named test.txt. In the environment using older version of zlib, the following code generates a…
1
vote
1 answer

When I download Excel files, strange files are stored

I want to download uploaded files such as .zip, .xlsm, xlsx, pdf... ..., etc., that have been uploaded, I want to eventually compress them into a zip file for download. However, if the uploaded files are not zipped, they will be downloaded with…
taizo
  • 77
  • 1
  • 8
1
vote
1 answer

RubyZip: archiving process indication

I am adding tons of file to my archive it looks like this: print "Starting ..." Zip::ZipFile.open(myarchive, 'w') do |zipfile| my_tons_of_files.each do |file| print "Adding #{file.filename} to archive ... \r" # ... end print "\n Saving…
fl00r
  • 82,987
  • 33
  • 217
  • 237
1
vote
1 answer

xlsx compressed by rubyzip not readable by Excel

I am working on writing code which can read/write Excel xlsx files. xlsx files are simply zip archives of several xml files, so in order to test out if I could write a file, I used a gem called rubyzip to unzip the xlsx file and then immediately zip…
vivek
  • 63
  • 1
  • 5
1
vote
1 answer

Zip end of central directory signature not found

I'm trying to allow for a user to upload a zipped folder containing xsl stylesheets. I then want to unzip the folder and save the folder in Rails.root/public/xsl/folderName Here's what I'm trying in my action: require…
Daniel Lawton
  • 416
  • 3
  • 9
  • 30
1
vote
0 answers

How to send the zip file in Rails via Grape API

I have a set of files that are present in s3 and I have to zip them all and send the zipped file to the front end(ReactJS). I am successfully able to create a folder in the tmp of the project and also zip them. Unfortunately, I get the error when I…
1
vote
0 answers

How to zip the list tempfiles with rubyzip gem

I have a list of tempfiles like this: urls = [#, #, #, #] now I want…
DinhNgocHien
  • 707
  • 3
  • 17
  • 34
1
vote
0 answers

Ruby on Rails and rubyzip: powerpoint modification corrupted on windows

I'm using ruby on rails to modify a powerpoint presentations existing template's xml files (open xml) based on data from my postgres database. The issue I am facing is that after the file is generated and downloaded from heroku using a windows…
1
vote
0 answers

How can I pass TraditionalDecrypter to rubyzip file from buffer

I'm trying to expand zip file included in raw mail message. My code is like Zip::File.open_buffer(attachment.data) do |zip| zip.each do |entry| # bellow works file puts entry.name # bellow cause Zlib::DataError: invalid block type …
Mekajiki
  • 911
  • 2
  • 8
  • 18