diff --git a/lib/fastimage.rb b/lib/fastimage.rb index 1428ee3..7486d9f 100644 --- a/lib/fastimage.rb +++ b/lib/fastimage.rb @@ -350,6 +350,7 @@ class FastImage end def fetch_using_file_open + @content_length = File.size?(@uri) File.open(@uri) do |s| fetch_using_read(s) end diff --git a/test/test.rb b/test/test.rb index 86afcf3..12c9630 100644 --- a/test/test.rb +++ b/test/test.rb @@ -152,6 +152,10 @@ class FastImageTest < Test::Unit::TestCase assert_equal info[1], FastImage.size(File.join(FixturePath, fn)) end end + + def test_should_report_content_length_correctly_for_local_files + assert_equal 3296, FastImage.new(File.join(FixturePath, "test.bmp")).content_length + end def test_should_report_type_correctly_for_ios GoodFixtures.each do |fn, info|