Class: CarrierWave::Storage::DirectDatabase
- Inherits:
-
Abstract
- Object
- Abstract
- CarrierWave::Storage::DirectDatabase
- Defined in:
- app/uploaders/polymorphic_uploader.rb
Overview
Database storage - puts the file contents in a database table
Defined Under Namespace
Classes: File
Instance Method Summary collapse
-
#retrieve!(identifier) ⇒ Object
Retrieve: Returns a file wrapper which accesses the database via the passed model.
-
#store!(file) ⇒ Object
Store: Takes a file object, passes it to a file wrapper class which handles storage in the DB.
Instance Method Details
#retrieve!(identifier) ⇒ Object
Retrieve: Returns a file wrapper which accesses the database via the passed model
16 17 18 |
# File 'app/uploaders/polymorphic_uploader.rb', line 16 def retrieve!(identifier) CarrierWave::Storage::DirectDatabase::File.new(uploader, self, uploader.store_path(identifier)) end |
#store!(file) ⇒ Object
Store: Takes a file object, passes it to a file wrapper class which handles storage in the DB
9 10 11 12 13 |
# File 'app/uploaders/polymorphic_uploader.rb', line 9 def store!(file) f = CarrierWave::Storage::DirectDatabase::File.new(uploader, self, uploader.store_path) f.store(file.read) f end |