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
1 answer

resource lock while generating the zip using Zipfilegenerator class, Ruby

I have an applicaiton in angularJS and ruby on rails. I am generating the subfolder and html files through code. Like my folder structure is like…
john
  • 611
  • 1
  • 7
  • 33
1
vote
1 answer

ENOENT while trying to read a zipped file

I'm writing a simple program that takes an input string, splits it in words and saves it in it's memory. There's three methods -- to save a string into memory, to load from file and to load from zip archive. Here's the code: require 'zip' class…
AlexNikolaev94
  • 1,169
  • 2
  • 16
  • 40
1
vote
2 answers

Rubyzip download attachments without creating the archive

I am using rubyzip with rails 4 and I am trying to make a custom method to download all the attachments in the submission table without phisically creating the zip file. submissions_controller.rb def download @submissions = Submission.all …
Vlad Balanescu
  • 664
  • 5
  • 27
1
vote
1 answer

md5sum of rubyzip output string and written file differs

I'm using rubyzip-1.2.0 with ruby 2.2.1 to generate a zip file containing a single file (in this case, a python script). The content file does not change, and the md5sum of the generated zip string remains the same, but once I write and then read…
Karen B
  • 2,693
  • 1
  • 17
  • 19
1
vote
1 answer

How to add require 'zip/zip' and 'zip' in Gem file

I have two ruby files where one file is using "require 'zip/zip'" with rubyzip version '0.0.9' and other "require 'zip'" with rubyzip version 1.1.7. If use them separately(alone) its working fine.If i combine i am getting error like "no such file to…
user1770589
  • 375
  • 1
  • 6
  • 19
1
vote
1 answer

ruby on rails the archive is in unknown format or damaged error upon send_data

I have the following code to zip some files and download it to the users desktop: def download info.find(params[:id]) if File.exists?("my_file.zip") File.delete("my_file.zip") end zipfile = Zip::ZipFile.open("my_file.zip",…
Micheal
  • 2,272
  • 10
  • 49
  • 93
1
vote
1 answer

ruby on rails file download binary files from the database and provide a link

I have 3 files in my mysql database. 2 of them is of type 'text' and 1 is 'longblob'. |username| |pem | |key | |cert | |test1 | |some text| |Some text | | Some binary text | |test2 | |some text| |Some text | | Some…
newbie
  • 1,023
  • 20
  • 46
1
vote
0 answers

Modifying files in a zip archive

I want to modify all of the files in a zip archive of XML files. When I tried to do this though, it tells me that the file doesn't exist. If I comment out the replace call though this works. What am I doing wrong? …
Xodarap
  • 11,581
  • 11
  • 56
  • 94
1
vote
1 answer

Rails 4: cannot install rubyzip

I am trying to install rubyzip into my Rails 4 app, but I keep getting cannot load such file errors. Here are the things I've tried: A. Gemfile: gem 'rubyzip' B. bundle install C. ...Using rubyzip 1.1.4... D. In my controller: require 'zip' E.…
user1002119
  • 3,692
  • 4
  • 27
  • 30
1
vote
1 answer

delete/remove temp zip file in ruby on rails

i am creating temp zip file in rails tmp directory as follows:- zipfile_name = Rails.root.join("tmp/abc.zip") Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile| Dir[File.join(data, '**',)].each do |file| zipfile.add(file.sub(dir+"/",…
Gaurav Sharma
  • 477
  • 9
  • 24
1
vote
1 answer

permission denied when using rubyzip

I'm trying to figure out a way to zip files using rubyzip. I rolled back to version 0.9.9 because the new version didn't work. below is the code I'm trying to test it with require 'rubygems' require 'zip/zip' folder = "/temp" input_filenames =…
Zach Smith
  • 8,458
  • 13
  • 59
  • 133
1
vote
0 answers

rubyzip with dynamic csv files

I had an application with rails 4 & rubyzip gem installed. I have 3 tables - students, exams & results. I followed this video http://railscasts.com/episodes/362-exporting-csv-and-excel I'm able to download individual table csv files but not all 3 at…
Buddy
  • 331
  • 3
  • 10
1
vote
0 answers

Does the RubyZip library support --fix option

In my code, I'm using the RubyZip library to create an archive Zip::File.open("1.zip", true) do |zf| Dir[File.join(Dir.pwd, '**', '**')].each do |f| zf.add(f, f) end end and then prepend a file with cat to the archive. After I…
jawerty
  • 155
  • 1
  • 2
  • 9
1
vote
2 answers

Undefined method Zip::ZipOutputStream.write_buffer on Heroku

I'm making a basic Sinatra app to play around with the Passbook gem. My app runs fine on localhost, but when I try and run it on Heroku I get this error message: /app/vendor/bundle/ruby/2.0.0/gems/passbook-0.2.1/lib/passbook/pkpass.rb:122:in…
GMA
  • 5,816
  • 6
  • 51
  • 80
1
vote
1 answer

Rails: "Zip::ZipError File not found"?

I have this action in my photos_controller def open_my_zip url = "http://www.vbaccelerator.com/home/VB/Code/vbMedia/Audio/Lossless_WAV_Compression/Sample_APE_File.zip" Zip::File.open(url) do |zipfile| zipfile.each do |file| # do…
goo
  • 2,230
  • 4
  • 32
  • 53