473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 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.


Regards,
amulyab
Feb 5 '09 #1
2 13565
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

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

Similar topics

13
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
0
by: stjulian | last post by:
On Windows Server 2003, IIS 6 I am looking for an unzipping component. I have a series of files that are available zipped at a considerable decrease in size. And before ASPINET fails on a script...
1
by: akiko | last post by:
i am student and i must to do project about web app by Ruby on rails i can not do past upload file.i try looking code but i just meet upload file image. i want to code upload file that it must to...
0
by: avik1612 | last post by:
Hi, I have created a program to unzip the file. It is unzipping the zip files when put in directory i.e folder inside folder but when i create a zip file without putting in a folder and try to...
2
by: =?Utf-8?B?cGVsZWdrMQ==?= | last post by:
i am uploading a zip file to the server and after the upload i want to unzip it how can i do this?thnaks in adbance peleg
2
by: hotflash | last post by:
Hi All, I found the best pure ASP code to upload a file to either server and/or MS Access Database. It works fine for me however, there is one thing that I don't like and have tried to fix but...
1
by: kss | last post by:
Hey all, I am new to python and I need to unzip a zip file which is password protected. I tried using zipfile class. Aparently, when i try doing a zip.read(filename), it throws an exception stating...
6
Jacotheron
by: Jacotheron | last post by:
I need a PHP script that can upload music files (mp3). The script is for a home project I have started a while ago. I have a MySQL database of all the music that I have. Other computers on the...
1
by: deepakd | last post by:
Hi I'm using wxZipInputStream for unzipping a zipped ".app" file in MAC OS.After unzipping i am not able to run the app.When i manually copy the unix executable to app packages, I am able to run...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.