Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

eullerborges
Copy link

Fixes #1177. I tried Content-MD5 as well, but that was more involved.

Copy link

@rampageservices rampageservices left a 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

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()

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing Content-MD5 http header for put request on object with bucket defined Lock
2 participants