* Add MediaFile abstraction. A MediaFile represents an image or video file. * Move filetype detection and dimension parsing code from uploads to MediaFile.
14 lines
297 B
Ruby
14 lines
297 B
Ruby
class MediaFile::Ugoira < MediaFile
|
|
def dimensions
|
|
tempfile = Tempfile.new
|
|
folder = Zip::File.new(file.path)
|
|
folder.first.extract(tempfile.path) { true }
|
|
|
|
image_file = MediaFile.open(tempfile)
|
|
image_file.dimensions
|
|
ensure
|
|
image_file.close
|
|
tempfile.close!
|
|
end
|
|
end
|