lib/carrierwave/storage/grid_fs.rb in locomotive_carrierwave-0.5.0.1 vs lib/carrierwave/storage/grid_fs.rb in locomotive_carrierwave-0.5.4.beta1

- old
+ new

@@ -9,11 +9,11 @@ # # There are two ways of configuring the GridFS connection. Either you create a # connection or you reuse an existing connection. # # Creating a connection looks something like this: - # + # # CarrierWave.configure do |config| # config.storage = :grid_fs # config.grid_fs_host = "your-host.com" # config.grid_fs_port = "27017" # config.grid_fs_database = "your_dbs_app_name" @@ -21,11 +21,11 @@ # config.grid_fs_password = "verysecret" # config.grid_fs_access_url = "/images" # end # # In the above example your documents url will look like: - # + # # http://your-app.com/images/:document-identifier-here # # When you already have a Mongo connection object (for example through Mongoid) # you can also reuse this connection: # @@ -43,11 +43,11 @@ @path = path @uploader = uploader end def path - nil + @path end def url unless @uploader.grid_fs_access_url nil @@ -59,11 +59,11 @@ def read grid.open(@path, 'r').data end def write(file) - grid.open(@uploader.store_path, 'w', :content_type => file.content_type) do |f| + grid.open(@uploader.store_path, 'w', :content_type => file.content_type) do |f| f.write(file.read) end end def delete @@ -71,11 +71,11 @@ end def content_type grid.open(@path, 'r').content_type end - + def file_length grid.open(@path, 'r').file_length end protected @@ -90,10 +90,10 @@ db = Mongo::Connection.new(host, port).db(database) db.authenticate(username, password) if username && password db end end - + def grid @grid ||= Mongo::GridFileSystem.new(database) end end