class CarrierWave::Storage::GridFS

The GridFS store uses MongoDB’s GridStore file storage system to store files

Public Instance Methods

retrieve!(identifier) click to toggle source

Retrieve the file from MongoDB’s GridFS GridStore

Parameters

identifier (String)

the filename of the file

Returns

CarrierWave::Storage::GridFS::File

a sanitized file

# File lib/carrierwave/storage/grid_fs.rb, line 101
def retrieve!(identifier)
  CarrierWave::Storage::GridFS::File.new(uploader, uploader.store_path(identifier))
end
store!(file) click to toggle source

Store the file in MongoDB’s GridFS GridStore

Parameters

file (CarrierWave::SanitizedFile)

the file to store

Returns

CarrierWave::SanitizedFile

a sanitized file

# File lib/carrierwave/storage/grid_fs.rb, line 84
def store!(file)
  stored = CarrierWave::Storage::GridFS::File.new(uploader, uploader.store_path)
  stored.write(file)
  stored
end