feat(Storage): Support user-provided hash validation in uploads#9164
Closed
salilg-eng wants to merge 1 commit intogoogleapis:mainfrom
Closed
feat(Storage): Support user-provided hash validation in uploads#9164salilg-eng wants to merge 1 commit intogoogleapis:mainfrom
salilg-eng wants to merge 1 commit intogoogleapis:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds support for users to provide pre-calculated
crc32candmd5checksums during object uploads for server-side validation in the Google Cloud Storage client library.Details:
Storage/src/Connection/Rest.php: UpdatedresolveUploadOptionsto extractcrc32candmd5from top-level arguments. These are now mapped to the correct object metadata (crc32candmd5Hash) and also included in theX-Goog-Hashheader if not already present. This ensures that the library skips auto-calculating hashes when the user provides them.Storage/src/Bucket.php: Documented the newcrc32candmd5options in the docblocks forupload()anduploadAsync()methods.Storage/tests/Unit/Connection/RestTest.php: Added unit tests (testInsertObjectWithUserProvidedHashes,testInsertObjectWithUserProvidedCrc32cOnly, andtestInsertObjectWithUserProvidedMd5Only) to verify that providing these options works as expected and skips auto-calculation.Storage/tests/System/UploadObjectsTest.php: Added system tests for both CRC32C and MD5 (both success and failure cases) to verify that GCS correctly validates or rejects uploads based on these top-level options.Fixes: b/332673668