400 Error digest_mismatch - File digest incorrect when committing chunked upload
I'm attempting to commit my session after I've uploaded all my file parts during a chunked upload session.
I'm getting back this error code:
[400 | 3938541613981df8929c15ab61e2c5b5] digest_mismatch - File digest was incorrect. Actual: J7tfRToRJhmT6BJAd46yQdUnS8U= Expected: n4AP7nqEWHxl1YeBizv4nh8yWRI=
for my digest I'm using
MessageDigest digest = null;
try {
digest = MessageDigest.getInstance("SHA1");
} catch (NoSuchAlgorithmException ae) {
throw new BoxAPIException("Digest algorithm not found", ae);
}
DigestInputStream dis = new DigestInputStream(stream, digest);
I upload my DigestInputStream in a loop with: session.uploadParts(dis, offset, partSize, fileSize);
Once loop is finished I create my file hash:
byte[] digestBytes = digest.digest();
Base64 encode the hash to a String with java.util.Base64
String digestStr = Base64.getEncoder().encodeToString(digestBytes);
commit the session
BoxFile.Info newFileInfo = session.commit(digestStr, parts, null, null, null);
Am I creating/encoding my digest wrong? How do I match what is expected from the Box Servers?
Thanks for your help
Please sign in to leave a comment.
Comments
1 comment