class Aws::Plugins::S3Md5s::Handler

@api private

Constants

OneMB

Public Instance Methods

call(context) click to toggle source
# File lib/aws-sdk-core/plugins/s3_md5s.rb, line 28
def call(context)
  body = context.http_request.body
  if body.size > 0
    context.http_request.headers['Content-Md5'] ||= md5(body)
  end
  @handler.call(context)
end
md5(body) click to toggle source
# File lib/aws-sdk-core/plugins/s3_md5s.rb, line 36
def md5(body)
  md5 = OpenSSL::Digest::MD5.new
  while chunk = body.read(OneMB)
    md5.update(chunk)
  end
  body.rewind
  Base64.encode64(md5.digest).strip
end