Sha256: f263cbbe3c2882dbfaa121d386bfe074fe3ca3c6b5321a93213d0d5b71f8317d

Contents?: true

Size: 820 Bytes

Versions: 12

Compression:

Stored size: 820 Bytes

Contents

module Vzaar
  module Uploaders
    class S3 < Struct.new(:path, :signature)
      SEND_TIMEOUT = 1800

      def upload
        client = HTTPClient.new
        client.send_timeout = SEND_TIMEOUT
        begin
          file = File.open(path)
          res = client.post url, [
            ['acl', signature.acl],
            ['bucket', signature.bucket],
            ['success_action_status', '201'],
            ['policy', signature.policy],
            ['AWSAccessKeyId', signature.access_key_id],
            ['signature', signature.signature],
            ['key', signature.key],
            ['file', file]
          ]
        ensure
          file.close if file
        end
        res.status_code == 201
      end

      def url
        "https://#{signature.bucket}.s3.amazonaws.com/"
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
vzaar-1.5.3 lib/vzaar/uploaders/s3.rb
vzaar-1.5.2 lib/vzaar/uploaders/s3.rb
vzaar-1.5.1 lib/vzaar/uploaders/s3.rb
vzaar-1.5.0 lib/vzaar/uploaders/s3.rb
vzaar-1.4.4 lib/vzaar/uploaders/s3.rb
vzaar-1.4.1 lib/vzaar/uploaders/s3.rb
vzaar-1.3.1 lib/vzaar/uploaders/s3.rb
vzaar-1.3.0 lib/vzaar/uploaders/s3.rb
vzaar-1.2.4 lib/vzaar/uploaders/s3.rb
vzaar-1.2.3 lib/vzaar/uploaders/s3.rb
vzaar-1.2.2 lib/vzaar/uploaders/s3.rb
vzaar-1.0.0 lib/vzaar/uploaders/s3.rb