472,133 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,133 software developers and data experts.

Unzipping a file on upload in Ruby

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.

Feb 5 '09 #1
2 13072
303 Expert 100+
Maybe ZipFileSystem or Archive::Tar::Minitar.
Feb 5 '09 #2
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
Mar 24 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by stjulian | last post: by
2 posts views Thread by =?Utf-8?B?cGVsZWdrMQ==?= | last post: by
1 post views Thread by kss | last post: by
6 posts views Thread by Jacotheron | last post: by
1 post views Thread by deepakd | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.