class CarrierWave::Storage::UcloudFile

Attributes

bucket[R]
path[R]

Public Class Methods

new(uploader, base, path) click to toggle source
# File lib/carrierwave/storage/ucloud_file.rb, line 6
def initialize(uploader, base, path)
  @uploader = uploader
  @path     = path
  @base     = base
  @bucket   = ::CarrierWave::Ucloud::Bucket.new(uploader)
end

Public Instance Methods

content_type() click to toggle source
# File lib/carrierwave/storage/ucloud_file.rb, line 40
def content_type
  headers[:content_type]
end
content_type=(new_content_type) click to toggle source
# File lib/carrierwave/storage/ucloud_file.rb, line 44
def content_type=(new_content_type)
  headers[:content_type] = new_content_type
end
delete() click to toggle source
# File lib/carrierwave/storage/ucloud_file.rb, line 28
def delete
  bucket.delete(path)
end
exists?() click to toggle source

Returns

Boolean

Whether the file exists

# File lib/carrierwave/storage/ucloud_file.rb, line 18
def exists?
  bucket.exists?(path)
end
headers() click to toggle source
# File lib/carrierwave/storage/ucloud_file.rb, line 48
def headers
  @headers ||= {}
end
read() click to toggle source
# File lib/carrierwave/storage/ucloud_file.rb, line 22
def read
  response = bucket.get(path)
  @headers = response.headers.deep_transform_keys { |k| k.underscore.to_sym rescue key }
  response.body
end
store(file, headers = {}) click to toggle source
# File lib/carrierwave/storage/ucloud_file.rb, line 36
def store(file, headers = {})
  bucket.put(path, file, headers)
end
url() click to toggle source
# File lib/carrierwave/storage/ucloud_file.rb, line 32
def url
  bucket.url(path)
end