My user uploads a zip file with 3 files (A.ttf, A.svg, A.otf), and I want to save the original zip plus 3 font files inside it. I created 3 versions with this code
version :ttf
process :font => :ttf
end
version :svg
process :font => :svg
end
version :otf
process :font => :otf
end
It successfully saves 4 copies of the source file, all with the correct file name. However, I do not know how to force CarrierWave to store separate files. This code does not work.: (
def font(format)
new_file = nil
Zip::ZipFile.open(@file.file) do |files|
files.each do |f|
next unless f.file?
filename = f.name.split("/").last
ext = filename.split('.').last
new_file = f if ext == format
end
new_file
end
source
share