assert md != null;
String contentDigest = Hex.encodeHexString(md.digest());
if (!contentDigest.equals(digest)) {
file.delete();
throw new DigestMismatchException(digest, contentDigest);
}
File newFile = container.getFile(digest);
file.renameTo(newFile);
return newFile;
}