class CarrierWave::Storage::S3cn::File

Public Class Methods

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

Public Instance Methods

content_type() click to toggle source
# File lib/carrierwave/s3cn/storage.rb, line 83
def content_type
  file_info[:content_type] || 'application/octet-stream'
end
delete() click to toggle source
# File lib/carrierwave/s3cn/storage.rb, line 79
def delete
  s3cn_connection.delete(@path)
end
etag() click to toggle source
# File lib/carrierwave/s3cn/storage.rb, line 91
def etag
  file_info[:etag]
end
meta() click to toggle source
# File lib/carrierwave/s3cn/storage.rb, line 95
def meta
  file_info[:meta]
end
path() click to toggle source
# File lib/carrierwave/s3cn/storage.rb, line 67
def path
  @path
end
size() click to toggle source
# File lib/carrierwave/s3cn/storage.rb, line 87
def size
  file_info[:content_length] || 0
end
store(file) click to toggle source
# File lib/carrierwave/s3cn/storage.rb, line 75
def store(file)
  s3cn_connection.store(file, @path)
end
url() click to toggle source
# File lib/carrierwave/s3cn/storage.rb, line 71
def url
  s3cn_connection.download_url(@path)
end

Private Instance Methods

file_info() click to toggle source
# File lib/carrierwave/s3cn/storage.rb, line 118
def file_info
  @file_info ||= s3cn_connection.info(@path)
end
s3cn_connection() click to toggle source
# File lib/carrierwave/s3cn/storage.rb, line 101
def s3cn_connection
  if @s3cn_connection
    @s3cn_connection
  else
    config = {
      :s3cn_region              => @uploader.s3cn_region,
      :s3cn_endpoint            => @uploader.s3cn_endpoint,
      :s3cn_bucket              => @uploader.s3cn_bucket,
      :s3cn_access_key_id       => @uploader.s3cn_access_key_id,
      :s3cn_secret_access_key   => @uploader.s3cn_secret_access_key,
      :s3cn_bucket_private      => @uploader.s3cn_bucket_private,
      :s3cn_protocol            => @uploader.s3cn_protocol
    }
    @s3cn_connection ||= Connection.new config
  end
end