/** * Unmarshalls a string header, taking into account whether it's a Base 64 encoded JSON value. * * @param value Value to unmarshall * @param field {@link SdkField} containing metadata about member being unmarshalled. * @return Unmarshalled value. */ private static String unmarshallStringHeader(String value, SdkField<String> field) { return field.containsTrait(JsonValueTrait.class) ? new String(BinaryUtils.fromBase64(value), StandardCharsets.UTF_8) : value; }
/** * Unmarshalls a string header, taking into account whether it's a Base 64 encoded JSON value. * * @param value Value to unmarshall * @param field {@link SdkField} containing metadata about member being unmarshalled. * @return Unmarshalled value. */ private static String unmarshallStringHeader(String value, SdkField<String> field) { return field.containsTrait(JsonValueTrait.class) ? new String(BinaryUtils.fromBase64(value), StandardCharsets.UTF_8) : value; }
private static SdkBytes toSdkBytes(String s) { return SdkBytes.fromByteArray(BinaryUtils.fromBase64(s)); }
private static SdkBytes toSdkBytes(String s) { return SdkBytes.fromByteArray(BinaryUtils.fromBase64(s)); }
/** * Client side validation for {@link PutObjectRequest} * * @param response the response * @param executionAttributes the execution attributes */ public static void validatePutObjectChecksum(PutObjectResponse response, ExecutionAttributes executionAttributes) { SdkChecksum checksum = executionAttributes.getAttribute(CHECKSUM); if (response.eTag() != null) { String contentMd5 = BinaryUtils.toBase64(checksum.getChecksumBytes()); byte[] digest = BinaryUtils.fromBase64(contentMd5); byte[] ssHash = Base16Lower.decode(response.eTag().replace("\"", "")); if (!Arrays.equals(digest, ssHash)) { throw SdkClientException.create("Data read has a different checksum than expected."); } } }