-
-
Notifications
You must be signed in to change notification settings - Fork 905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide sha256 checksum with file updates #1353
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo needs fixing.
Suggest improvement for readability.
@@ -1725,6 +1726,10 @@ def send_file(self, request, stream, labels, buffer = '', throttle = 0, | |||
sha256_hash = checksum_sha256_file(stream, offset, size_total) | |||
request.body = sha256_hash | |||
|
|||
# Provide the checksum with teh request. This is important for buckets that have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"the" is spelled incorrectly here, shown as "teh". Minor typo.
@@ -1725,6 +1726,10 @@ def send_file(self, request, stream, labels, buffer = '', throttle = 0, | |||
sha256_hash = checksum_sha256_file(stream, offset, size_total) | |||
request.body = sha256_hash | |||
|
|||
# Provide the checksum with teh request. This is important for buckets that have | |||
# Object Lock enabled. | |||
headers['x-amz-checksum-sha256'] = base64.b64encode(sha256_hash.digest()).decode() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
base64.b64encode(sha256_hash.digest()).decode()
Can this line be broken down? It is doing a lot all at once. It is hard for readability.
Perhaps we canpull out the digest operation into a separate sha256_hash_digest variable?
Or maybe this functionality can be separated into a new function in S3/Crypto.py
I know this exact line is recommended online in tutorials but is in my opinion hard to read.
See: https://debugpointer.com/python/sha256-to-base64-python
Fixes #1177. I tried
Content-MD5
as well, but that was more involved.