Skip to content

Instantly share code, notes, and snippets.

@trevorrowe
Created May 7, 2015 16:32
Show Gist options
  • Save trevorrowe/61dd9f550445bc32b3b7 to your computer and use it in GitHub Desktop.
Save trevorrowe/61dd9f550445bc32b3b7 to your computer and use it in GitHub Desktop.
IO wrapper sample
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