class Aws::S3::Plugins::Md5s::Handler
@api private
def call(context)
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
def md5(value)
-
(String
-)
Parameters:
-
value
(File, Tempfile, IO#read, String
) --
def md5(value) if (File === value || Tempfile === value) && !value.path.nil? && File.exist?(value.path) Base64.encode64(OpenSSL::Digest::MD5.file(value).digest).strip elsif value.respond_to?(:read) md5 = OpenSSL::Digest::MD5.new update_in_chunks(md5, value) Base64.encode64(md5.digest).strip else Base64.encode64(OpenSSL::Digest::MD5.digest(value)).strip end end
def update_in_chunks(digest, io)
def update_in_chunks(digest, io) while chunk = io.read(CHUNK_SIZE) digest.update(chunk) end io.rewind end