From c9fb178a6c962bec5e6f743f998d6efe4e211740 Mon Sep 17 00:00:00 2001 From: stopdropandrew Date: Mon, 8 Sep 2008 18:27:30 -0700 Subject: [PATCH] * lib/parkplace/s3.rb: Change how content-md5 matches to follow Amazon's formats (base64 encoded digest instead of hexdigest). --- lib/parkplace/s3.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/parkplace/s3.rb b/lib/parkplace/s3.rb index 9cceb30..b2f5a12 100644 --- a/lib/parkplace/s3.rb +++ b/lib/parkplace/s3.rb @@ -115,11 +115,11 @@ def put(bucket_name, oid) fileinfo.mime_type = @env.HTTP_CONTENT_TYPE || "binary/octet-stream" fileinfo.disposition = @env.HTTP_CONTENT_DISPOSITION fileinfo.size = readlen - fileinfo.md5 = md5.hexdigest + fileinfo.md5 = Base64.encode64(md5.digest).strip raise IncompleteBody if @env.HTTP_CONTENT_LENGTH.to_i != readlen if @env.HTTP_CONTENT_MD5 - raise InvalidDigest unless @env.HTTP_CONTENT_MD5 =~ /^[0-9a-fA-F]{32}$/ + raise InvalidDigest unless @env.HTTP_CONTENT_MD5 =~ /^(?:[0-9a-zA-Z+\/]{4})*={0,2}$/ raise BadDigest unless fileinfo.md5 == @env.HTTP_CONTENT_MD5 end