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

Rails: open .zip tempfile outside application

I'm trying to upload a .zip file and then parse it using rubyzip: def upload require 'zip' @file = params[:software].tempfile Zip::File.open(@file.path) do |zipfile| #Parse file... end end I can't do this, I get a File not found error…
bpromas
  • 684
  • 1
  • 11
  • 25
0
votes
1 answer

Memory usage when unzipping files with rubyzip

I'm using rubyzip to unzip some files during a rake task, but Im finding that the memory used isn't available after unzipping the files. I have to reboot the server to reclaim the memory. Anyone else having similar issues? Any workarounds? I'm…
Jeff Locke
  • 617
  • 1
  • 6
  • 17
0
votes
1 answer

how to make this method more efficient Rails 3?

i want to make my method more efficient. my method take so much time in response. so please edit my code to get more efficient response.i am very thank full to you if you make this method more more efficient. and you are master in ruby on rails then…
Faysal
  • 47
  • 1
  • 9
0
votes
0 answers

Ruby Zip file not found. when file exists

I am using ruby zip for the first time to read files and i keep getting the error file not found. i even tried putting the file in my public directory and i am still getting the exact same error but if i enter the file location im my address bar the…
Uchenna
  • 4,059
  • 6
  • 40
  • 73
0
votes
1 answer

rails rubyzip make a copy of multiple zip files inside a new zipfile

So basically I am creating a bunch of zip files which contains a pwe and pws files inside it. The following code generates a bunch of zip files which is named as orgname_org_member_orguser1.zip which contains 2 files(a pws and pwe) …
Micheal
  • 2,272
  • 10
  • 49
  • 93
0
votes
0 answers

Rails 4. Gem creating. Include rubyzip gem

I'm creating my own gem(mountable plugin), and I need to include an older version of rubyzip gem. The reason for using the old version is that I have some code templates written in Rails 3. In the gemfile I include the old version as follows: gem…
0
votes
1 answer

Rubyzip - possible to set extraction folder?

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 Windows as self-extractable. Is this option available in Rubyzip? Or is this a value that is stored in the…
TheImdal
  • 53
  • 6
0
votes
1 answer

Collection of activerecord objects in pdf format to zip

I have a complicated problem with creating zip file containing collection of active record object in pdf format. I have invoices controller and in this controller I have action show which looks like this: def show add_breadcrumb "Inovice…
Mateusz Urbański
  • 7,352
  • 15
  • 68
  • 133
0
votes
1 answer

Save image from ZIP file using rubyzip, paperclip, and rails 4

Let me start by saying I'm open to a better way to do this, but here's what I have so far. Lets say I have a zip file with 100 images in it. I want to loop through the zip file and 'attach' each image to a record. I have Paperclip installed to…
jmcharnes
  • 707
  • 12
  • 23
0
votes
2 answers

Cannot install watir on ruby 2.0 because of rubyzip

I'm trying to install watir. Had to upgrade my ruby installation so I installed rvenv and then used it to install ruby v2.0. Sagis-MacBook-Air:~ sagism$ rbenv shell 2.0.0-rc2 Sagis-MacBook-Air:~ sagism$ ruby -v ruby 2.0.0dev (2013-02-08 trunk…
sagism
  • 881
  • 4
  • 11
  • 18
0
votes
1 answer

Rubyzip and zipruby for zip/unzip not creating much difference in the compressed zipfile size

i have been using rubyzip for zip/unzip for files/folder ranging from 20MB TO 1GB.i noticed that after zipping a folder of 20MB,the created zipfile is almost of the same size somewhat 20MB.So is rubyzip just zip the file or actually compresses it…
Milind
  • 4,535
  • 2
  • 26
  • 58
0
votes
1 answer

How create zip file using rubyzip on heroku

I am working with creating zip file after read users cv's. Code is working fine on local machine. But there is error when deploy this code on heroku. def get_stream(contractors) #t = Tempfile.new("my-temp-filename-#{Time.now}") #this code on…
Kashiftufail
  • 10,815
  • 11
  • 45
  • 79
0
votes
1 answer

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…
rswolff
  • 3,258
  • 5
  • 28
  • 31
0
votes
1 answer

Ruby Zip #glob method seems to be selecting a directory. Why?

I'm using RubyZip to access the files inside of a Zip directory. Zip::ZipFile.open(self.package.to_s) do |zipfile| zipfile.glob("**/*.*").each {|file| update_or_save(file)} end RubyZip has a similar #glob method to Ruby Dir#glob. From my…
Paul
  • 2,021
  • 5
  • 22
  • 33
0
votes
1 answer

Using Ruby to create ZIP archives containing UTF-8 encoded "files" without using the file system

Using zipruby it is beautifully easy to create a ZIP archive without writing to disk. One can take strings and add them as archive entries and finally get the entire archive as a string. I can then send it as an attachment to the web service that is…
1 2 3
9
10