From b2814c1125fb1097af49ac46e0c9a47997d6e6c8 Mon Sep 17 00:00:00 2001 From: lllusion3469 <31420484+lllusion3469@users.noreply.github.com> Date: Mon, 25 May 2020 18:43:03 +0200 Subject: [PATCH] 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 --- app/logical/media_file/flash.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/logical/media_file/flash.rb b/app/logical/media_file/flash.rb index be0f8c829..f7e4c8c5c 100644 --- a/app/logical/media_file/flash.rb +++ b/app/logical/media_file/flash.rb @@ -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