uploads: fix getting dimensions of flash files

MediaFile#dimensions is called twice - in #width and in #height but
it only works on the first call because the file is read to the end and
consumed the first time so when #read is called the second time it only
returns the empty string
This commit is contained in:
lllusion3469
2020-05-25 18:43:03 +02:00
parent c300b344de
commit b2814c1125

View File

@@ -5,7 +5,7 @@ class MediaFile::Flash < MediaFile
def dimensions
# Read the entire stream into memory because the
# dimensions aren't stored in a standard location
contents = file.read.force_encoding("ASCII-8BIT")
contents = File.read(file.path, binmode: true).force_encoding("ASCII-8BIT")
# Our 'signature' is the first 3 bytes
# Either FWS or CWS. CWS indicates compression