I'm trying to extract an uploaded zip file and store its contents in the database, one entry per file. The rubyzip library has nearly no useful documentation.
There is an assets table that has key :string (file name) and data :binary (file contents).
I'm using the rubyzip library, and have made it as far as this:
Zip::ZipFile.open(@file_data.local_path) do |zipfile|
zipfile.each do |entry|
next if entry.name =~ /__MACOSX/ or entry.name =~ /\.DS_Store/ or !entry.file?
asset = self.assets.build
asset.key = entry.name
asset.data = ?? # what goes here?
end
end
How can I set the data from a ZipEntry? Do I have to use a temp file?