Class: CarrierWave::Storage::Raca::File

Inherits:
Object
  • Object
show all
Defined in:
lib/carrierwave/storage/raca.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, , path)
  @uploader = uploader
  @account  = 
  @path     = path
end

Instance Attribute Details

#accountObject (readonly)

Returns the value of attribute account.



23
24
25
# File 'lib/carrierwave/storage/raca.rb', line 23

def 
  @account
end

#content_typeObject



36
37
38
# File 'lib/carrierwave/storage/raca.rb', line 36

def content_type
  @content_type || [:content_type]
end

#pathObject (readonly)

Returns the value of attribute path.



23
24
25
# File 'lib/carrierwave/storage/raca.rb', line 23

def path
  @path
end

#uploaderObject (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

#attributesObject

is this required?



32
33
34
# File 'lib/carrierwave/storage/raca.rb', line 32

def attributes
  
end

#deleteObject



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

Returns:

  • (Boolean)


51
52
53
# File 'lib/carrierwave/storage/raca.rb', line 51

def exists?
   != nil
end

#extensionObject



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(options = {})
  if file_url = url(options)
    file_url.gsub(/.*\/(.*?$)/, '\1')
  end
end

#readObject



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

#sizeObject



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_fileObject



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(options = {})
  if uploader.asset_host
    "#{uploader.asset_host}/#{path}"
  else
    path
  end
end