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
7
votes
2 answers

Zipping a directory in Rails

How do i go about zipping a directory in ruby on rails? I've tried rubyzip without success. I don't need to zip the contents of the dir individually just zip the dir itself.
delvison
  • 149
  • 3
  • 9
6
votes
6 answers

zipruby or rubyzip?

I've got a ruby on rails site here (rails 2.0.2, ruby 1.8.6) with both rubyzip and zipruby installed, but they conflict on the File.exists? method so I want to remove one. What's the general consensus out there on the best zipping api going…
vaughanos
  • 521
  • 5
  • 10
6
votes
2 answers

Rubyzip vs native OS compression

I am wondering what would be the performance difference when zipping data using rubyzip as compared to using native os libraries for performing the compression. I am fetching data to be compressed from a URL and then using the ZipOutputStream to…
randomuser
  • 1,858
  • 2
  • 17
  • 21
6
votes
2 answers

How do I get a temporary File object (of correct content-type, without writing to disk) directly from a ZipEntry (RubyZip, Paperclip, Rails 3)?

I'm currently trying to attach image files to a model directly from a zip file (i.e. without first saving them on a disk). It seems like there should be a clearer way of converting a ZipEntry to a Tempfile or File that can be stored in memory to be…
Josh Kovach
  • 7,679
  • 3
  • 45
  • 62
6
votes
1 answer

generate ZIP from generated PDFs with wicked_pdf

In my invoice system, I want a backup function to download all invoices at once in one zip file. This system is running on heroku - so it's only possible to save the pdfs temporary. I've the rubyzip and wicked_pdf gem installed. My current code in…
Adrian
  • 524
  • 5
  • 21
6
votes
1 answer

What might explain an "invalid stored block lengths" error?

I am running a Rails (3.2.3) application with Ruby 1.9.3p194 on the basic Ubuntu lucid32 image in a Vagrant virtual box. The virtual box is running on Leopard, for what it's worth. I'm trying to use rubyzip in the application to decompress a zip…
Steve Rowley
  • 1,548
  • 1
  • 11
  • 18
5
votes
1 answer

Subdirectories in Zip file using ZipOutputStream

I am creating a zip file using the technique described here: http://info.michael-simons.eu/2008/01/21/using-rubyzip-to-create-zip-files-on-the-fly/ The client has asked that I include subdirectories in this zip file. I have searched the…
Scott Rice
  • 1,165
  • 1
  • 10
  • 16
5
votes
0 answers

Xlsx file gives error on MS Excel once it is zipped using rubyzip and unzipped on windows

Actually my requirement is to zip some files in some folders. I have already many files saved on my server and associated with some objects. So I have to zip all the files related to one object somewhat like this: Main Folder Sub Folder Another…
Deepesh
  • 6,138
  • 1
  • 24
  • 41
5
votes
2 answers

Set compression level when generating a ZIP file using RubyZip

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…
Vincent Robert
  • 35,564
  • 14
  • 82
  • 119
5
votes
1 answer

rubyZip Gem: Want to zip remote files in RoR

I want to download photos from my website after zipping. I am using rubyZip gem but unable to zip remote files. Following is the scenario: I am trying to zip content from server. Content is something like…
tahniyat
  • 75
  • 1
  • 6
4
votes
1 answer

rubyzip Zip::ZipFile.open_buffer expects an argument of class String or IO

I am reading blob data from the database which is zipped(the contents of file is in CSV). The result of my variable looks like this: irb(main):144:0> my_string =>…
Micheal
  • 2,272
  • 10
  • 49
  • 93
4
votes
0 answers

rubyzip - private method `open' called for Zip::File:Class (Ruby on Rails 4)

I've added a helper method to my Application controller: def unzip (file, destination) Zip::File.open(file) do |zip_file| zip_file.each do |f| f_path = File.join(destination, f.name) …
astronomotrous
  • 431
  • 1
  • 3
  • 12
4
votes
2 answers

In rails, can i check if an uploaded zip file is corrupt or invalid?

I have a ruby app in which freelancers can complete jobs for an employer. When the job complete, the freelancer can upload files for the employer to review. I think the freelancer should be able to upload zip files, but i don't want the freelancer…
Philip7899
  • 4,599
  • 4
  • 55
  • 114
4
votes
3 answers

rubyzip - cannot load such file -- zip

I am attempting to use rubyzip to create zip archives on the fly in my app. I'm using their readme as a starting point. I added the gem to my Gemfile: gem 'rubyzip' Then ran bundle install and restarted the rails server. My controller code…
seancdavis
  • 2,739
  • 2
  • 26
  • 36
4
votes
2 answers

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?
Gerhard
  • 6,850
  • 8
  • 51
  • 81
1
2
3
9 10