module Paperclip::Storage::S3::AwsS3Library
Mixin which interfaces with the 'aws-s3' library.
Protected Instance Methods
s3_connect!()
click to toggle source
# File lib/dm-paperclip/storage/s3/aws_s3_library.rb, line 8 def s3_connect! AWS::S3::Base.establish_connection!(@s3_options.merge( :access_key_id => @s3_credentials[:access_key_id], :secret_access_key => @s3_credentials[:secret_access_key] )) end
s3_create_bucket()
click to toggle source
# File lib/dm-paperclip/storage/s3/aws_s3_library.rb, line 27 def s3_create_bucket AWS::S3::Bucket.create(bucket_name) end
s3_delete(key)
click to toggle source
# File lib/dm-paperclip/storage/s3/aws_s3_library.rb, line 50 def s3_delete(key) begin AWS::S3::S3Object.delete(key, bucket_name) rescue AWS::S3::ResponseError # Ignore this. end end
s3_download(key,file)
click to toggle source
# File lib/dm-paperclip/storage/s3/aws_s3_library.rb, line 23 def s3_download(key,file) file.write(AWS::S3::S3Object.value(key, bucket_name)) end
s3_exists?(key)
click to toggle source
# File lib/dm-paperclip/storage/s3/aws_s3_library.rb, line 19 def s3_exists?(key) AWS::S3::S3Object.exists?(key, bucket_name) end
s3_expiring_url(key,time)
click to toggle source
# File lib/dm-paperclip/storage/s3/aws_s3_library.rb, line 15 def s3_expiring_url(key,time) AWS::S3::S3Object.url_for(key, bucket_name, :expires_in => time) end
s3_store(key,file)
click to toggle source
# File lib/dm-paperclip/storage/s3/aws_s3_library.rb, line 31 def s3_store(key,file) begin AWS::S3::S3Object.store( key, file, bucket_name, { :content_type => instance_read(:content_type), :access => @s3_permissions, }.merge(@s3_headers) ) rescue AWS::S3::NoSuchBucket => e s3_create_bucket retry rescue AWS::S3::ResponseError => e raise end end