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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions S3/S3.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
## --------------------------------------------------------------------

from __future__ import absolute_import, division
import base64

import sys
import os
Expand Down Expand Up @@ -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.

# 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


if use_expect_continue:
if not size_total:
use_expect_continue = False
Expand Down