-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
4117: Added Md5String() method and updated tests. #4397
Conversation
@frankyn, would you please take a look at this PR. |
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.
@andrey-qlogic adding this feature to the client sg. I recommend adding the same for crc32c as well.
Added Crc32cString() method and updated tests. Added to snippets. |
Hi @andrey-qlogic, Thanks for the update. I chatted with the GCS team about this design. It sounds good to them but suggested adding a Hex Hash String to GCS base64 encoded string for setCrc32c() method to the The naming convention would help: @googleapis/yoshi-java do you have input on Java community method names? WDYT about the following names? getMd5ToHexString()
setMd5FromHexString()
getCrc32cToHexString()
setCrc32cFromHexString() |
…, getCrc32cToHexString()
Renamed new methods using naming convention getMd5ToHexString(), getCrc32cToHexString(). |
The other method setMd5 for example expects the base64 encoded string of an Md5 hash. It would be nice to have a similar helper method to getting the md5 hash as a base64 decoded md5 hex string. |
@frankyn, that is unclear, are you suggesting to add a new setter method to class BuilderImpl and assign it to md5 ? Otherwise the method getMd5ToHexString is implepented for BlobInfo class in 85588a3 I would appreciate for your input |
I'm expecting to see // pseudo code
setMd5FromHexString(String md5HexString) {
// convert md5HexString back to its binary representation e.g. reverse binary to human readable hex.
// base64 encode the binary representation
// set the value of Md5 in BlobInfo to the base64 encoded version.
} |
Added methods to set Md2 and Crc32s from hex strings. |
there are code format issues that will be fixed with #4437 |
google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/BlobInfo.java
Outdated
Show resolved
Hide resolved
@frankyn, I realized that Md5 sometimes used with 0x prefix that can be easily removed at BlobInfo class. |
For this PR, @andrey-qlogic could you skip supporting the removal of "0x" for now? Thank you, apologies for constant delays on these reviews. |
Yes except the integration test. |
Reverted back the commit 7f19e33 except integration tests. |
google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/BlobInfo.java
Outdated
Show resolved
Hide resolved
google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/BlobInfo.java
Outdated
Show resolved
Hide resolved
… prepending 0x. OmitPadding removed
@frankyn |
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.
I think this is the last nits. Thanks for your patience @andrey-qlogic.
...ud-clients/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITStorageTest.java
Show resolved
Hide resolved
...ud-clients/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITStorageTest.java
Outdated
Show resolved
Hide resolved
google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/BlobInfo.java
Outdated
Show resolved
Hide resolved
google-cloud-clients/google-cloud-storage/src/test/java/com/google/cloud/storage/BlobTest.java
Outdated
Show resolved
Hide resolved
@frankyn , I realized that new BigInteger(md5HexString, 16).toByteArray() is not safe with leading zeros. I changed to DatatypeConverter.parseHexBinary(md5HexString). It works fine. If needed we can make an utility method instead. |
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.
LGTM, I notice you dropped, DatatypeConverter.parseHexBinary(md5HexString)
due to supportability. Thanks for verifying that!
thanks for the approval |
Fixes #4117