瀏覽代碼

HUE-7794 [fb] Modify/upload file failed if S3 bucket encryption is SSE-KMS

  When server side encryption is AES256 (SSE-S3) or no SSE, etag equals to md5.
  But when it is aws:kms (SSE-KMS) and HTTP Method is PUT, the md5 is not match.
  http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPUT.html
Ying Chen 8 年之前
父節點
當前提交
37fa3f1
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      desktop/core/ext-py/boto-2.46.1/boto/s3/key.py

+ 6 - 1
desktop/core/ext-py/boto-2.46.1/boto/s3/key.py

@@ -977,7 +977,12 @@ class Key(object):
             server_side_encryption_customer_algorithm = response.getheader(
                 'x-amz-server-side-encryption-customer-algorithm', None)
             if server_side_encryption_customer_algorithm is None:
-                if self.etag != '"%s"' % md5:
+                server_side_encryption = response.getheader('x-amz-server-side-encryption', None)
+                # When server side encryption is AES256 (SSE-S3) or no SSE, etag equals to md5.
+                # But when it is aws:kms (SSE-KMS) and HTTP Method is PUT, the md5 is not match.
+                #
+                # http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPUT.html
+                if self.etag != '"%s"' % md5 and server_side_encryption != 'aws:kms' and response._method != 'PUT':
                     raise provider.storage_data_error(
                         'ETag from S3 did not match computed MD5. '
                         '%s vs. %s' % (self.etag, self.md5))