Close an upload session and create a file from the uploaded chunks.
D5E3F7A
The ID of the upload session.
The list details for the uploaded parts
sha=fpRyg5eVQletdZqEKaFlqwBXJzM=
The RFC3230 message digest of the whole file.
Only SHA1 is supported. The SHA1 digest must be Base64
encoded. The format of this header is as
sha=BASE64_ENCODED_DIGEST
.
1
Ensures this item hasn't recently changed before making changes.
Pass in the item's last observed etag
value
into this header and the endpoint will fail
with a 412 Precondition Failed
if it
has changed since.
1
Ensures an item is only returned if it has changed.
Pass in the item's last observed etag
value
into this header and the endpoint will fail
with a 304 Not Modified
if the item has not
changed since.
Returns the file object in a list.
Returns when all chunks have been uploaded but not yet processed.
Inspect the upload session to get more information about the progress of processing the chunks, then retry committing the file when all chunks have processed.
Returns an error if there is already a file with the same name in the target folder.
Returns an error if the If-Match
or If-None-Match
conditions fail.
An unexpected client error.
curl -X POST https://upload.box.com/api/2.0/files/upload_sessions/F971964745A5CD0C001BBE4E58196BFD/commit \
-H 'Authorization: Bearer <ACCESS_TOKEN>'
-H "Digest: sha=fpRyg5eVQletdZqEKaFlqwBXJzM=" \
-H 'Content-Type: application/json" '
-d '{
"parts": [
{
"part_id": "BFDF5379",
"offset": 0,
"size": 8388608,
"sha1": "134b65991ed521fcfe4724b7d814ab8ded5185dc"
},
{
"part_id": "E8A3ED8E",
"offset": 8388608,
"size": 1611392,
"sha1": "234b65934ed521fcfe3424b7d814ab8ded5185dc"
}
],
"attributes": {
"content_modified_at": "2017-04-08T00:58:08Z"
}
}'
//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('Successfully uploaded file {0} with description {1}'.format(uploaded_file.id, uploaded_file.description))
// Finalize upload session 93D9A837B45F
client.files.commitUploadSession(
'93D9A837B45F',
fileHash.digest('base64'),
{description: 'A file I uploaded in chunks!'},
callback
);