Class: CarrierWave::Storage::Abstract
- Inherits:
-
Object
- Object
- CarrierWave::Storage::Abstract
- Defined in:
- lib/carrierwave/storage/abstract.rb
Overview
This file serves mostly as a specification for Storage engines. There is no requirement that storage engines must be a subclass of this class. However, any storage engine must conform to the following interface:
The storage engine must respond to store!, taking an uploader object and a CarrierWave::SanitizedFile as parameters. This method should do something to store the given file, and then return an object.
The storage engine must respond to retrieve!, taking an uploader object and an identifier as parameters. This method should do retrieve and then return an object.
The objects returned by store! and retrieve! both must respond to identifier
, taking no arguments. Identifier is a string that uniquely identifies this file and can be used to retrieve it later.
Class Method Summary collapse
-
.destroy!(uploader, identifier) ⇒ Object
Do something to destroy the file.
-
.retrieve!(uploader, identifier) ⇒ Object
Do something to retrieve the file.
-
.setup! ⇒ Object
Do setup specific for this storage engine.
-
.store!(uploader, file) ⇒ Object
Do something to store the file.
Instance Method Summary collapse
-
#identifier ⇒ Object
Should return a String that uniquely identifies this file and can be used to retrieve it from the same storage engine later on.
-
#path ⇒ Object
Should return the path where the file is corrently located.
-
#url ⇒ Object
Should return the url where the file is publically accessible.
Class Method Details
.destroy!(uploader, identifier) ⇒ Object
Do something to destroy the file
Parameters
- uploader (CarrierWave::Uploader)
-
an uploader object
- identifier (String)
-
uniquely identifies the file
Returns
- bool
-
True if file was remove or false
33 34 35 |
# File 'lib/carrierwave/storage/abstract.rb', line 33 def self.destroy!(uploader, identifier) false end |
.retrieve!(uploader, identifier) ⇒ Object
Do something to retrieve the file
Parameters
- uploader (CarrierWave::Uploader)
-
an uploader object
- identifier (String)
-
uniquely identifies the file
Returns
- #identifier
-
an object
69 70 71 |
# File 'lib/carrierwave/storage/abstract.rb', line 69 def self.retrieve!(uploader, identifier) self.new end |
.setup! ⇒ Object
Do setup specific for this storage engine
40 |
# File 'lib/carrierwave/storage/abstract.rb', line 40 def self.setup!; end |
.store!(uploader, file) ⇒ Object
Do something to store the file
Parameters
- uploader (CarrierWave::Uploader)
-
an uploader object
- file (CarrierWave::SanitizedFile)
-
the file to store
Returns
- #identifier
-
an object
54 55 56 |
# File 'lib/carrierwave/storage/abstract.rb', line 54 def self.store!(uploader, file) self.new end |
Instance Method Details
#identifier ⇒ Object
Should return a String that uniquely identifies this file and can be used to retrieve it from the same storage engine later on.
This is OPTIONAL
Returns
- String
-
path to the file
83 |
# File 'lib/carrierwave/storage/abstract.rb', line 83 def identifier; end |
#path ⇒ Object
Should return the path where the file is corrently located. This is OPTIONAL.
This is OPTIONAL
Returns
- String
-
path to the file
106 |
# File 'lib/carrierwave/storage/abstract.rb', line 106 def path; end |
#url ⇒ Object
Should return the url where the file is publically accessible. If this is not set, then it is assumed that the url is the path relative to the public directory.
This is OPTIONAL
Returns
- String
-
file’s url
95 |
# File 'lib/carrierwave/storage/abstract.rb', line 95 def url; end |