Class: CarrierWave::Storage::Raca::File
- Inherits:
-
Object
- Object
- CarrierWave::Storage::Raca::File
- Defined in:
- lib/carrierwave/storage/raca.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
readonly
Returns the value of attribute account.
- #content_type ⇒ Object
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#uploader ⇒ Object
readonly
Returns the value of attribute uploader.
Instance Method Summary collapse
-
#attributes ⇒ Object
is this required?.
- #delete ⇒ Object
- #exists? ⇒ Boolean
- #extension ⇒ Object
- #filename(options = {}) ⇒ Object
-
#initialize(uploader, account, path) ⇒ File
constructor
A new instance of File.
- #read ⇒ Object
- #size ⇒ Object
- #store(new_file) ⇒ Object
- #to_file ⇒ Object
- #url(options = {}) ⇒ Object
Constructor Details
#initialize(uploader, account, path) ⇒ File
Returns a new instance of File.
25 26 27 28 29 |
# File 'lib/carrierwave/storage/raca.rb', line 25 def initialize(uploader, account, path) @uploader = uploader @account = account @path = path end |
Instance Attribute Details
#account ⇒ Object (readonly)
Returns the value of attribute account.
23 24 25 |
# File 'lib/carrierwave/storage/raca.rb', line 23 def account @account end |
#content_type ⇒ Object
36 37 38 |
# File 'lib/carrierwave/storage/raca.rb', line 36 def content_type @content_type || [:content_type] end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
23 24 25 |
# File 'lib/carrierwave/storage/raca.rb', line 23 def path @path end |
#uploader ⇒ Object (readonly)
Returns the value of attribute uploader.
23 24 25 |
# File 'lib/carrierwave/storage/raca.rb', line 23 def uploader @uploader end |
Instance Method Details
#attributes ⇒ Object
is this required?
32 33 34 |
# File 'lib/carrierwave/storage/raca.rb', line 32 def attributes end |
#delete ⇒ Object
40 41 42 43 44 45 |
# File 'lib/carrierwave/storage/raca.rb', line 40 def delete container.delete(path) rescue ::Raca::NotFoundError # if the file doesn't exist on cloud files, then deleting it was a no-op anyway true end |
#exists? ⇒ Boolean
51 52 53 |
# File 'lib/carrierwave/storage/raca.rb', line 51 def exists? != nil end |
#extension ⇒ Object
47 48 49 |
# File 'lib/carrierwave/storage/raca.rb', line 47 def extension path.split('.').last end |
#filename(options = {}) ⇒ Object
55 56 57 58 59 |
# File 'lib/carrierwave/storage/raca.rb', line 55 def filename( = {}) if file_url = url() file_url.gsub(/.*\/(.*?$)/, '\1') end end |
#read ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/carrierwave/storage/raca.rb', line 61 def read tempfile = Tempfile.new("carrierwave-raca") tempfile.close container.download(path, tempfile.path) ::File.read(tempfile.path) ensure tempfile.unlink if tempfile end |
#size ⇒ Object
70 71 72 |
# File 'lib/carrierwave/storage/raca.rb', line 70 def size [:bytes] end |
#store(new_file) ⇒ Object
74 75 76 |
# File 'lib/carrierwave/storage/raca.rb', line 74 def store(new_file) container.upload(path, new_file.file, "Content-Type" => new_file.content_type) end |
#to_file ⇒ Object
78 79 80 |
# File 'lib/carrierwave/storage/raca.rb', line 78 def to_file # is this needed? end |
#url(options = {}) ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/carrierwave/storage/raca.rb', line 82 def url( = {}) if uploader.asset_host "#{uploader.asset_host}/#{path}" else path end end |