Sha256: aad7a72f2943462a7ba4762e22c522aa8849b2f38e4aa49cae34ea6a2a76b332

Contents?: true

Size: 800 Bytes

Versions: 5

Compression:

Stored size: 800 Bytes

Contents

module Pageflow
  module Panorama
    class S3Bucket
      attr_reader :bucket

      def initialize(bucket)
        @bucket = bucket
      end

      def write(name:, input_stream:, content_length:, content_type:)
        object = bucket.object(name)

        object.put(body: StreamWithSize.new(input_stream, content_length),
                   acl: 'public-read',
                   content_type: content_type,
                   content_length: content_length)
      end

      class StreamWithSize < SimpleDelegator
        attr_reader :size

        def initialize(stream, size)
          super(stream)
          @size = size
        end
      end

      class Factory
        def from_attachment(attachment)
          S3Bucket.new(attachment.s3_bucket)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pageflow-panorama-2.4.0 lib/pageflow/panorama/s3_bucket.rb
pageflow-panorama-2.3.0 lib/pageflow/panorama/s3_bucket.rb
pageflow-panorama-2.2.0 lib/pageflow/panorama/s3_bucket.rb
pageflow-panorama-2.1.0 lib/pageflow/panorama/s3_bucket.rb
pageflow-panorama-2.0.0 lib/pageflow/panorama/s3_bucket.rb