lib/pageflow/panorama/s3_bucket.rb in pageflow-panorama-1.0.1 vs lib/pageflow/panorama/s3_bucket.rb in pageflow-panorama-2.0.0

- old
+ new

@@ -6,14 +6,24 @@ def initialize(bucket) @bucket = bucket end def write(name:, input_stream:, content_length:, content_type:) - object = bucket.objects[name] - object.write(input_stream, - acl: :public_read, - content_type: content_type, - content_length: content_length) + 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)