469,326 Members | 1,359 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,326 developers. It's quick & easy.

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.


Regards,
amulyab
Feb 5 '09 #1
2 12263
improvcornartist
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
Jacotheron
6 posts views Thread by Jacotheron | last post: by
1 post views Thread by deepakd | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.