Sha256: 32cf41b26c95e94be4e2bcbf6db39def845b175d9cc6191170d4add94196a50a

Contents?: true

Size: 1.27 KB

Versions: 12

Compression:

Stored size: 1.27 KB

Contents

require 'fog'

module Heirloom
  module AWS
    class S3

      def initialize(args)
        @config = args[:config]
        @region = args[:region]

        @s3 = Fog::Storage.new :provider              => 'AWS',
                               :aws_access_key_id     => @config.access_key,
                               :aws_secret_access_key => @config.secret_key,
                               :region                => @region
      end

      def delete_object(bucket_name, object_name, options = {})
        @s3.delete_object(bucket_name, object_name, options)
      end

      def get_bucket(bucket)
        @s3.directories.get bucket
      end

      def delete_bucket(bucket)
        @s3.delete_bucket bucket
      end

      def get_object(bucket_name, object_name)
        @s3.get_object(bucket_name, object_name).body
      end

      def get_bucket_acl(bucket)
        @s3.get_bucket_acl(bucket).body
      end

      def put_object_acl(bucket, key, grants)
        @s3.put_object_acl(bucket, key, grants)
      end

      def put_bucket(bucket_name, region)
        region = nil if region == 'us-east-1'
        options = { 'LocationConstraint' => region,
                    'x-amz-acl'          => 'private' }
        @s3.put_bucket bucket_name, options
      end

    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
heirloom-0.8.1 lib/heirloom/aws/s3.rb
heirloom-0.8.0 lib/heirloom/aws/s3.rb
heirloom-0.7.4 lib/heirloom/aws/s3.rb
heirloom-0.7.3 lib/heirloom/aws/s3.rb
heirloom-0.7.3rc2 lib/heirloom/aws/s3.rb
heirloom-0.7.3rc1 lib/heirloom/aws/s3.rb
heirloom-0.7.2 lib/heirloom/aws/s3.rb
heirloom-0.7.2rc2 lib/heirloom/aws/s3.rb
heirloom-0.7.2rc1 lib/heirloom/aws/s3.rb
heirloom-0.7.1 lib/heirloom/aws/s3.rb
heirloom-0.7.0 lib/heirloom/aws/s3.rb
heirloom-0.7.0rc1 lib/heirloom/aws/s3.rb