public String addBlob(String tempFilePath) {
try {
File file = new File(tempFilePath);
InputStream in = new FileInputStream(file);
MessageDigest messageDigest = MessageDigest.getInstance(HASH_ALGORITHM);
DigestInputStream din = new DigestInputStream(in, messageDigest);
long length = file.length();
try {
while (true) {
int len = din.read(buffer, 0, buffer.length);
if (len < 0) {
break;
}
}
} finally {
din.close();
}
ByteArrayOutputStream idStream = new ByteArrayOutputStream();
idStream.write(TYPE_HASH);
IOUtils.writeVarInt(idStream, 0);
IOUtils.writeVarLong(idStream, length);