Class: CarrierWave::Storage::NosFile

Inherits:
CarrierWave::SanitizedFile
  • Object
show all
Defined in:
lib/carrierwave/storage/nos_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uploader, base, path) ⇒ NosFile

Returns a new instance of NosFile.



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

def initialize(uploader, base, path)
  @uploader = uploader
  @base = base
  @path = URI.encode(path)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



4
5
6
# File 'lib/carrierwave/storage/nos_file.rb', line 4

def path
  @path
end

Instance Method Details

#readObject



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

def read
  object = bucket.get(@path)
  @headers = object.headers
  object
end

#store(file) ⇒ Object



18
19
20
# File 'lib/carrierwave/storage/nos_file.rb', line 18

def store(file)
  bucket.put(@path, file)
end

#url(_opts = {}) ⇒ Object



22
23
24
# File 'lib/carrierwave/storage/nos_file.rb', line 22

def url(_opts = {})
  bucket.path_to_url(@path)
end