Sha256: 7f6ca1d7cc46b3f7b41485982abd9d1888e3eb6b6d3c0c95d42477bcbdba23d4
Contents?: true
Size: 513 Bytes
Versions: 11
Compression:
Stored size: 513 Bytes
Contents
class BrickLayer::ServeGridFsFile class << self def call(env) if env["PATH_INFO"] =~ /^\/files\/(.+)$/ process_request(env, $1) end end private def process_request(env, key) begin Mongo::GridFileSystem.new(Mongoid.database).open(key, 'r') do |file| [200, { 'Content-Type' => file.content_type }, [file.read]] end rescue [404, { 'Content-Type' => 'text/plain' }, ['File not found.']] end end end end
Version data entries
11 entries across 11 versions & 1 rubygems