class CarrierWave::Storage::CloudFiles::File

Public Instance Methods

content_type() click to toggle source
# File lib/carrierwave/storage/cloud_files.rb, line 81
def content_type
  cf_container.object(@path).content_type
end
content_type=(new_content_type) click to toggle source
# File lib/carrierwave/storage/cloud_files.rb, line 85
def content_type=(new_content_type)
  headers["content-type"] = new_content_type
end
delete() click to toggle source

Remove the file from Cloud Files

# File lib/carrierwave/storage/cloud_files.rb, line 61
def delete
  cf_container.delete_object(@path)
end
path() click to toggle source

Returns the current path/filename of the file on Cloud Files.

Returns

String

A path

# File lib/carrierwave/storage/cloud_files.rb, line 41
def path
  @path
end
read() click to toggle source

Reads the contents of the file from Cloud Files

Returns

String

contents of the file

# File lib/carrierwave/storage/cloud_files.rb, line 52
def read
  object = cf_container.object(@path)
  @content_type = object.content_type
  object.data
end
store(data,headers={}) click to toggle source

Writes the supplied data into the object on Cloud Files.

Returns

boolean

# File lib/carrierwave/storage/cloud_files.rb, line 96
def store(data,headers={})
  object = cf_container.create_object(@path)
  object.write(data,headers)
end
url() click to toggle source

Returns the url on the Cloud Files CDN. Note that the parent container must be marked as public for this to work.

Returns

String

file’s url

# File lib/carrierwave/storage/cloud_files.rb, line 73
def url
  if @uploader.cloud_files_cdn_host
    "http://" + @uploader.cloud_files_cdn_host + "/" + @path
  else
    cf_container.object(@path).public_url
  end
end

Public Class Methods

new(uploader, base, path) click to toggle source
# File lib/carrierwave/storage/cloud_files.rb, line 28
def initialize(uploader, base, path)
  @uploader = uploader
  @path = path
  @base = base
end