Connecting Tech Pros Worldwide Help | Site Map

Unzipping a file on upload in Ruby

  #1  
Old February 5th, 2009, 05:04 AM
Newbie
 
Join Date: Oct 2007
Posts: 19
Hello everyone,
I am uploading a zipped file where in which i need the unzipped file should get extracted to some target directory after uploading. I tried by using rubyzip gem,but its not working.Please help me how can i do this.


Regards,
amulyab
  #2  
Old February 5th, 2009, 02:44 PM
Expert
 
Join Date: May 2007
Posts: 213

re: Unzipping a file on upload in Ruby


Maybe ZipFileSystem or Archive::Tar::Minitar.
  #3  
Old March 24th, 2009, 01:34 PM
Newbie
 
Join Date: Oct 2007
Posts: 19

re: Unzipping a file on upload in Ruby


Hello all,
I got a method for uploading a zipped file and extract its folder and save in a directory.


Expand|Select|Wrap|Line Numbers
  1.  Zip::ZipFile.open(file_path) { |zip_file|
  2.      zip_file.each { |f|
  3.      f_path=File.join("destination_path", f.name)
  4.      FileUtils.mkdir_p(File.dirname(f_path))
  5.      zip_file.extract(f, f_path) unless File.exist?(f_path)
  6.    }
  7.   }
Hope it helps.Thanks

Last edited by eWish; April 28th, 2009 at 01:58 PM. Reason: Please use the code tags
Reply