Class: CarrierWave::Storage::DirectDatabase

Inherits:
Abstract
  • Object
show all
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

Instance Method Details

#retrieve!(identifier) ⇒ Object

Retrieve: Returns a file wrapper which accesses the database via the passed model


15
16
17
# File 'app/uploaders/polymorphic_uploader.rb', line 15

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


8
9
10
11
12
# File 'app/uploaders/polymorphic_uploader.rb', line 8

def store!(file)
  f = CarrierWave::Storage::DirectDatabase::File.new(uploader, self, uploader.store_path)
  f.store(file.read)
  f
end