Skip to content

Commit

Permalink
* lib/parkplace/s3.rb: Change how content-md5 matches to follow Amaz…
Browse files Browse the repository at this point in the history
…on's formats (base64 encoded digest instead of hexdigest).
  • Loading branch information
stopdropandrew authored and _why committed Sep 9, 2008
1 parent 39c21c1 commit c9fb178
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/parkplace/s3.rb
Expand Up @@ -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

Expand Down

0 comments on commit c9fb178

Please sign in to comment.