# File lib/carrierwave/storage/grid_fs.rb, line 44 def content_type grid.open(@path, 'r').content_type end
# File lib/carrierwave/storage/grid_fs.rb, line 40 def delete grid.delete(@path) end
# File lib/carrierwave/storage/grid_fs.rb, line 48 def file_length grid.open(@path, 'r').file_length end
# File lib/carrierwave/storage/grid_fs.rb, line 18 def path nil end
# File lib/carrierwave/storage/grid_fs.rb, line 30 def read grid.open(@path, 'r').data end
# File lib/carrierwave/storage/grid_fs.rb, line 22 def url unless @uploader.grid_fs_access_url nil else [@uploader.grid_fs_access_url, @path].join("/") end end
# File lib/carrierwave/storage/grid_fs.rb, line 34 def write(file) grid.open(@uploader.store_path, 'w', :content_type => file.content_type) do |f| f.write(file.read) end end
# File lib/carrierwave/storage/grid_fs.rb, line 54 def database @connection ||= begin host = @uploader.grid_fs_host port = @uploader.grid_fs_port database = @uploader.grid_fs_database username = @uploader.grid_fs_username password = @uploader.grid_fs_password db = Mongo::Connection.new(host, port).db(database) db.authenticate(username, password) if username && password db end end
# File lib/carrierwave/storage/grid_fs.rb, line 67 def grid @grid ||= Mongo::GridFileSystem.new(database) end
# File lib/carrierwave/storage/grid_fs.rb, line 13 def initialize(uploader, path) @path = path @uploader = uploader end