// Note that java collections cannot effectively do equals or hashcodes on
// byte arrays, so let's convert to a list of bytes.
List<Byte> md5 = Bytes.asList(content.getContentMetadata().getContentMD5());
// Request an upload site for this file
UploadSandbox site = api.createUploadSandboxForChecksums(ImmutableSet.of(md5));
assertTrue(site.getChecksums().containsKey(md5), md5 + " not in " + site.getChecksums());
try {
// Upload the file contents, if still not uploaded
ChecksumStatus status = site.getChecksums().get(md5);
if (status.needsUpload()) {
api.uploadContent(status.getUrl(), content);
}
Sandbox sandbox = api.commitSandbox(site.getSandboxId(), true);
assertTrue(sandbox.isCompleted(), "Sandbox should be completed after uploading");
} catch (RuntimeException e) {
api.commitSandbox(site.getSandboxId(), false);
fail("Could not upload content");
}
// Create the metadata of the cookbook
Metadata metadata = Metadata.builder() //