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

feat: add configurable checksum support for uploads #139

Merged
merged 8 commits into from Jul 23, 2020
Merged

Conversation

andrewsg
Copy link
Contributor

Adds configurable checksum support for MultipartUpload and ResumableUpload.

SimpleUpload is not supported because the GCS json API does not accept checksums defined in headers, only in metadata.

MultipartUpload is checked server-side as originally intended for uploads, and a failure will return a 400 error (InvalidResponse exception). ResumableUpload is checked locally as a workaround for having no way to submit the checksum for server-side uploads, as the metadata is transmitted only in the first chunk. A failure there will result in a DataCorruption exception.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jul 15, 2020
@tseaver tseaver changed the title feat: configurable checksum support for uploads feat: add configurable checksum support for uploads Jul 16, 2020
Copy link
Member

@frankyn frankyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main request is to handle when metadata passes in md5 or crc32c AND user wants auto md5/crc32c enabled.

Otherwise implementation looks good.

return checksum_type


def prepare_checksum_digest(digest_bytestring):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be prefixed _?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several other helper functions that are similarly independent of internal specifics are public in this file so I decided this one should be intentionally public as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's the case should the file name be renamed to helpers.py instead in the case an end-user wants to use them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that would be productive as it would commit us to a public interface and there is no expressed customer demand for that, but I wanted to follow the previous convention of not marking functions in this private module further private if they aren't extremely single-use and don't make strong assumptions about internal structure.

google/resumable_media/requests/download.py Outdated Show resolved Hide resolved
google/resumable_media/_upload.py Show resolved Hide resolved
google/resumable_media/_helpers.py Show resolved Hide resolved
return checksum_type


def prepare_checksum_digest(digest_bytestring):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's the case should the file name be renamed to helpers.py instead in the case an end-user wants to use them?

@andrewsg
Copy link
Contributor Author

PTAL (also, this revision unit and system tests for system-native strings (unicode in py3 and bytes in py2) to ensure everything works as users will actually use the software).

Copy link
Member

@frankyn frankyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @andrewsg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants