Skip to content

Commit

Permalink
Return GridIO object instead of file contents
Browse files Browse the repository at this point in the history
GridIO implements `each`, so Rack can stream files in chunks
  • Loading branch information
ches committed Jan 5, 2011
1 parent b34d0c9 commit 565d566
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rack/gridfs.rb
Expand Up @@ -38,7 +38,7 @@ def call(env)

def gridfs_request(id)
file = Mongo::Grid.new(db).get(BSON::ObjectId.from_string(id))
[200, {'Content-Type' => file.content_type}, [file.read]]
[200, {'Content-Type' => file.content_type}, file]
rescue Mongo::GridFileNotFound, BSON::InvalidObjectId
[404, {'Content-Type' => 'text/plain'}, ['File not found.']]
end
Expand Down

0 comments on commit 565d566

Please sign in to comment.