module Paperclip::Storage::S3::AwsLibrary

Mixin which interfaces with the 'aws' and 'right_aws' libraries.

Protected Instance Methods

s3_connect!() click to toggle source
# File lib/dm-paperclip/storage/s3/aws_library.rb, line 8
def s3_connect!
  @s3 = Aws::S3.new(
    @s3_credentials[:access_key_id],
    @s3_credentials[:secret_access_key]
  )
  @s3_bucket = @s3.bucket(bucket_name)
end
s3_delete(key) click to toggle source
# File lib/dm-paperclip/storage/s3/aws_library.rb, line 35
def s3_delete(key)
  @s3_bucket.key(key).delete
end
s3_download(key,file) click to toggle source
# File lib/dm-paperclip/storage/s3/aws_library.rb, line 24
def s3_download(key,file)
  @s3_bucket.key(key).get { |chunk| file.write(chunk) }
end
s3_exists?(key) click to toggle source
# File lib/dm-paperclip/storage/s3/aws_library.rb, line 20
def s3_exists?(key)
  @s3_bucket.keys(:prefix => key).any? { |s3_key| s3_key.name == key }
end
s3_expiring_url(key,time) click to toggle source
# File lib/dm-paperclip/storage/s3/aws_library.rb, line 16
def s3_expiring_url(key,time)
  @s3.interface.get_link(bucket_name,key,time)
end
s3_store(key,file) click to toggle source
# File lib/dm-paperclip/storage/s3/aws_library.rb, line 28
def s3_store(key,file)
  @s3_bucket.key(key).put(
    file,
    @s3_permissions.to_s.gsub('_','-')
  )
end