Class: CarrierWave::Storage::Riak::File

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uploader, path) ⇒ File

Returns a new instance of File.



7
8
9
10
# File 'lib/carrierwave/storage/riak.rb', line 7

def initialize(uploader, path)
  @uploader = uploader
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/carrierwave/storage/riak.rb', line 5

def path
  @path
end

Instance Method Details

#content_typeObject



27
28
29
# File 'lib/carrierwave/storage/riak.rb', line 27

def content_type
  robject.content_type
end

#deleteObject



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

def delete
  robject.delete
end

#readObject



19
20
21
# File 'lib/carrierwave/storage/riak.rb', line 19

def read
  @read ||= robject.raw_data
end

#sizeObject



31
32
33
# File 'lib/carrierwave/storage/riak.rb', line 31

def size
  read.length
end

#urlObject



35
36
37
# File 'lib/carrierwave/storage/riak.rb', line 35

def url
  robject.url
end

#write(file) ⇒ Object



12
13
14
15
16
17
# File 'lib/carrierwave/storage/riak.rb', line 12

def write(file)
  robject = bucket.new(key)
  robject.content_type = file.content_type
  robject.raw_data = file.read
  robject.store
end