//Creates the file hash
byte[] digestBytes = digest.digest();
//Base64 encoding of the hash
String digestStr = Base64.encode(digestBytes);
//Commit the upload session. If there is a failure, abort the commit.
BoxFile.Info fileInfo = session.commit(digestStr, parts, null, null, null);
import hashlib
sha1 = hashlib.sha1()
# sha1 should have been updated with all the bytes of the file
file_atributes = {
'description': 'A file uploaded via Chunked Upload',
}
upload_session = client.upload_session('11493C07ED3EABB6E59874D3A1EF3581')
uploaded_file = upload_session.commit(sha1.digest(), file_atributes=file_atributes)
print(f'Successfully uploaded file {uploaded_file.id} with description {uploaded_file.description}')
// Finalize upload session 93D9A837B45F
client.files.commitUploadSession(
'93D9A837B45F',
fileHash.digest('base64'),
{description: 'A file I uploaded in chunks!'},
callback
);
Additionally, any file attributes can be passed along with the parts to
further add information to the file. See the POST /files/content
API for more details.
When successful, the API returns a HTTP 201 Created status code with a
File object.
In some cases, creating the parts might not be ready yet and the API will return
a 202 Accepted status code instead. In this case the application should check
the retry-after header and retry committing after the number of seconds
specified.