Created
May 7, 2015 16:32
-
-
Save trevorrowe/61dd9f550445bc32b3b7 to your computer and use it in GitHub Desktop.
IO wrapper sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProgressIO | |
def initialize(io) | |
@io = io | |
end | |
def read(bytes = nil, output_buffer = nil) | |
puts bytes | |
@io.read(bytes, output_buffer) | |
end | |
def rewind(*args) | |
@io.rewind(*args) | |
end | |
def size(*args) | |
@io.size(*args) | |
end | |
end | |
s3 = Aws::S3::Client.new | |
s3.handle do |context| | |
context.http_request.body = ProgressIO.new(context.http_request.body) | |
@handler.call(context) | |
end | |
data = StringIO.new('.' * 1024 * 1024) # 1MB | |
s3.put_object(bucket:'aws-sdk', key:'key', body:data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment