@Override
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
checkArgument(checkNotNull(input, "input") instanceof AtmosObject, "this binder is only valid for AtmosObject!");
checkNotNull(request, "request");
AtmosObject object = AtmosObject.class.cast(input);
checkNotNull(object.getPayload(), "object payload");
checkArgument(object.getPayload().getContentMetadata().getContentLength() != null,
"contentLength must be set, streaming not supported");
byte[] contentMD5 = object.getContentMetadata().getContentMD5();
if (contentMD5 != null) {
request = (R) request.toBuilder()
.addHeader(AtmosHeaders.CHECKSUM, "MD5/0/" +
BaseEncoding.base16().encode(contentMD5))
.build();
}
return metaBinder.bindToRequest(request, object.getUserMetadata());
}