Class: CarrierWave::Storage::GridFS
- Defined in:
- lib/carrierwave/storage/grid_fs.rb
Overview
The GridFS store uses MongoDB’s GridStore file storage system to store files
Defined Under Namespace
Classes: File
Instance Attribute Summary
Attributes inherited from Abstract
Instance Method Summary collapse
-
#retrieve!(identifier) ⇒ Object
Retrieve the file from MongoDB’s GridFS GridStore.
-
#store!(file) ⇒ Object
Store the file in MongoDB’s GridFS GridStore.
Methods inherited from Abstract
Constructor Details
This class inherits a constructor from CarrierWave::Storage::Abstract
Instance Method Details
#retrieve!(identifier) ⇒ Object
Retrieve the file from MongoDB’s GridFS GridStore
Parameters
- identifier (String)
-
the filename of the file
Returns
- CarrierWave::Storage::GridFS::File
-
a sanitized file
98 99 100 |
# File 'lib/carrierwave/storage/grid_fs.rb', line 98 def retrieve!(identifier) CarrierWave::Storage::GridFS::File.new(uploader, uploader.store_path(identifier)) end |
#store!(file) ⇒ Object
Store the file in MongoDB’s GridFS GridStore
Parameters
- file (CarrierWave::SanitizedFile)
-
the file to store
Returns
- CarrierWave::SanitizedFile
-
a sanitized file
81 82 83 84 85 |
# File 'lib/carrierwave/storage/grid_fs.rb', line 81 def store!(file) stored = CarrierWave::Storage::GridFS::File.new(uploader, uploader.store_path) stored.write(file) stored end |