Hello,
Can we use/overwrite HTTP headers such as USER_AGENT when invoking methods like
BlobStore.putBlob() or we need to specify the BlobRequestSigner and use
HttpClient instead?
For example, if I want to include the HTTP headers in the following operation:
ByteSource input = ByteSource.wrap(“BLAH”.getBytes(StandardCharsets.UTF_8));
Blob blob = blobStore
.blobBuilder(“NAME")
.payload(input)
.contentLength(input.size())
.contentMD5(input.hash(Hashing.md5()))
.contentType("text/plain")
.build();
blobStore.putBlob(container, blob);
Should I use the BlobRequestSigner as follows? Is this the right approach?
final BlobRequestSigner signer = blobStoreInfo.getBlobRequestSigner();
HttpRequest request = signer.signPutBlob(container, blob)
.toBuilder()
.addHeader(HttpHeaders.CONTENT_LENGTH,
String.valueOf(input.size()))
.addHeader(HttpHeaders.USER_AGENT, “custom agent")
.payload(input)
.build();
HttpClient httpClient = blobStore.getContext().utils().http());
httpClient.invoke(request);
Thank you,
Ashkan