diff --git a/lib/mongo/gridfs/grid_store.rb b/lib/mongo/gridfs/grid_store.rb index 126026a..4011909 100644 --- a/lib/mongo/gridfs/grid_store.rb +++ b/lib/mongo/gridfs/grid_store.rb @@ -54,6 +54,9 @@ module GridFS # Default is DEFAULT_CONTENT_TYPE attr_accessor :content_type + # Size of file in bytes + attr_reader :length + attr_accessor :metadata attr_reader :files_id diff --git a/test/test_grid_store.rb b/test/test_grid_store.rb index d2c5a01..71a161b 100644 --- a/test/test_grid_store.rb +++ b/test/test_grid_store.rb @@ -71,6 +71,10 @@ class GridStoreTest < Test::Unit::TestCase assert_equal "hello", GridStore.read(@@db, 'foobar', 5) end + def test_access_length + assert_equal 13, GridStore.new(@@db, 'foobar').length + end + # Also tests seek def test_read_with_offset assert_equal "world", GridStore.read(@@db, 'foobar', 5, 7)