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
I'd use the rubyzip gem. Specifically this part: https://github.com/rubyzip/rubyzip/blob/master/lib/zip/filesystem.rb
It creates an artificial file system in memory mirroring the contents of the zip file. Here's an example based of the example from the docs:
Rubyzip interface changed!!! No need to do require "zip/zip" and Zip prefix in class names removed.
require 'zip'
Zip::File.open("my.zip") do |zipfile|
zipfile.each do |file|
# do something with file
end
end
In your case, just put the name of the uploaded tempfile where my.zip
is in the example, and you can loop through the contents and do your regular operations on them.