How do i go about zipping a directory in ruby on rails? I've tried rubyzip without success. I don't need to zip the contents of the dir individually just zip the dir itself.
相关问题
- Question marks after images and js/css files in ra
- Using :remote => true with hover event
- Eager-loading association count with Arel (Rails 3
- How to specify memcache server to Rack::Session::M
- Why am I getting a “C compiler cannot create execu
相关文章
- Ruby using wrong version of openssl
- Right way to deploy Rails + Puma + Postgres app to
- AWS S3 in rails - how to set the s3_signature_vers
- Difference between Thread#run and Thread#wakeup?
- how to call a active record named scope with a str
- How to add a JSON column in MySQL with Rails 5 Mig
- “No explicit conversion of Symbol into String” for
- form_for wrong number of arguments in rails 4
You can create an archive of the directory using tar
tar -cvf your_dir.tar your_dir/
and then compress the tar in rails using -
Its already answered at Rails 3: How do I generate a compressed file on request
You are going to have to loop through the items in the directory to add an entry in the compressed file.
Another way to do it with a command
Update
Thank you Mahmoud Khaled for the edit/update
for the new version use
Zip::File.open
instead ofZip::ZipFile.open