I\'m uploading a file to the server in Ruby on Rails
Normally, it\'s a text file and I save it in the model as a \'file\' field in a Submission ActiveRecord with oth
Worked for me:
gem install rubyzip
main.rb
require 'zip'
def extract_zip(file, destination)
FileUtils.mkdir_p(destination)
Zip::File.open(file) do |zip_file|
zip_file.each do |f|
fpath = File.join(destination, f.name)
FileUtils.mkdir_p(File.dirname(fpath))
zip_file.extract(f, fpath) unless File.exist?(fpath)
end
end
end
extract_zip('file.zip', 'tmp')