This is a manager for chunked uploads (allowed for files at least 20MB).
- Create upload session
- Create upload session for existing file
- Get upload session by URL
- Get upload session
- Upload part of file by URL
- Upload part of file
- Remove upload session by URL
- Remove upload session
- List parts by URL
- List parts
- Commit upload session by URL
- Commit upload session
- Upload big file
Creates an upload session for a new file.
This operation is performed by calling function create_file_upload_session.
See the endpoint docs at API Reference.
client.chunked_uploads.create_file_upload_session(
parent_folder_id, file_size, file_name
)- folder_id
str- The ID of the folder to upload the new file to.
- file_size
int- The total number of bytes of the file to be uploaded.
- file_name
str- The name of new file.
- extra_headers
Optional[Dict[str, Optional[str]]]- Extra headers that will be included in the HTTP request.
This function returns a value of type UploadSession.
Returns a new upload session.
Creates an upload session for an existing file.
This operation is performed by calling function create_file_upload_session_for_existing_file.
See the endpoint docs at API Reference.
Currently we don't have an example for calling create_file_upload_session_for_existing_file in integration tests
- file_id
str- The unique identifier that represents a file. The ID for any file can be determined by visiting a file in the web application and copying the ID from the URL. For example, for the URL
https://*.app.box.com/files/123thefile_idis123. Example: "12345"
- The unique identifier that represents a file. The ID for any file can be determined by visiting a file in the web application and copying the ID from the URL. For example, for the URL
- file_size
int- The total number of bytes of the file to be uploaded.
- file_name
Optional[str]- The optional new name of new file.
- extra_headers
Optional[Dict[str, Optional[str]]]- Extra headers that will be included in the HTTP request.
This function returns a value of type UploadSession.
Returns a new upload session.
Return information about an upload session.
The actual endpoint URL is returned by the Create upload session endpoint.
This operation is performed by calling function get_file_upload_session_by_url.
See the endpoint docs at API Reference.
client.chunked_uploads.get_file_upload_session_by_url(status_url)- url
str- URL of getFileUploadSessionById method
- extra_headers
Optional[Dict[str, Optional[str]]]- Extra headers that will be included in the HTTP request.
This function returns a value of type UploadSession.
Returns an upload session object.
Return information about an upload session.
The actual endpoint URL is returned by the Create upload session endpoint.
This operation is performed by calling function get_file_upload_session_by_id.
See the endpoint docs at API Reference.
client.chunked_uploads.get_file_upload_session_by_id(upload_session_id)- upload_session_id
str- The ID of the upload session. Example: "D5E3F7A"
- extra_headers
Optional[Dict[str, Optional[str]]]- Extra headers that will be included in the HTTP request.
This function returns a value of type UploadSession.
Returns an upload session object.
Uploads a chunk of a file for an upload session.
The actual endpoint URL is returned by the Create upload session
and Get upload session endpoints.
This operation is performed by calling function upload_file_part_by_url.
See the endpoint docs at API Reference.
client.chunked_uploads.upload_file_part_by_url(
acc.upload_part_url,
generate_byte_stream_from_buffer(chunk_buffer),
digest,
content_range,
)- url
str- URL of uploadFilePart method
- request_body
ByteStream- Request body of uploadFilePart method
- digest
str- The [RFC3230][1] message digest of the chunk uploaded. Only SHA1 is supported. The SHA1 digest must be base64 encoded. The format of this header is as
sha=BASE64_ENCODED_DIGEST. To get the value for theSHAdigest, use the openSSL command to encode the file part:openssl sha1 -binary <FILE_PART_NAME> | base64. [1]: https://tools.ietf.org/html/rfc3230
- The [RFC3230][1] message digest of the chunk uploaded. Only SHA1 is supported. The SHA1 digest must be base64 encoded. The format of this header is as
- content_range
str- The byte range of the chunk. Must not overlap with the range of a part already uploaded this session. Each part’s size must be exactly equal in size to the part size specified in the upload session that you created. One exception is the last part of the file, as this can be smaller. When providing the value for
content-range, remember that: _ The lower bound of each part's byte range must be a multiple of the part size. _ The higher bound must be a multiple of the part size - 1.
- The byte range of the chunk. Must not overlap with the range of a part already uploaded this session. Each part’s size must be exactly equal in size to the part size specified in the upload session that you created. One exception is the last part of the file, as this can be smaller. When providing the value for
- extra_headers
Optional[Dict[str, Optional[str]]]- Extra headers that will be included in the HTTP request.
This function returns a value of type UploadedPart.
Chunk has been uploaded successfully.
Uploads a chunk of a file for an upload session.
The actual endpoint URL is returned by the Create upload session
and Get upload session endpoints.
This operation is performed by calling function upload_file_part.
See the endpoint docs at API Reference.
client.chunked_uploads.upload_file_part(
acc.upload_session_id,
generate_byte_stream_from_buffer(chunk_buffer),
digest,
content_range,
)- upload_session_id
str- The ID of the upload session. Example: "D5E3F7A"
- request_body
ByteStream- Request body of uploadFilePart method
- digest
str- The [RFC3230][1] message digest of the chunk uploaded. Only SHA1 is supported. The SHA1 digest must be base64 encoded. The format of this header is as
sha=BASE64_ENCODED_DIGEST. To get the value for theSHAdigest, use the openSSL command to encode the file part:openssl sha1 -binary <FILE_PART_NAME> | base64. [1]: https://tools.ietf.org/html/rfc3230
- The [RFC3230][1] message digest of the chunk uploaded. Only SHA1 is supported. The SHA1 digest must be base64 encoded. The format of this header is as
- content_range
str- The byte range of the chunk. Must not overlap with the range of a part already uploaded this session. Each part’s size must be exactly equal in size to the part size specified in the upload session that you created. One exception is the last part of the file, as this can be smaller. When providing the value for
content-range, remember that: _ The lower bound of each part's byte range must be a multiple of the part size. _ The higher bound must be a multiple of the part size - 1.
- The byte range of the chunk. Must not overlap with the range of a part already uploaded this session. Each part’s size must be exactly equal in size to the part size specified in the upload session that you created. One exception is the last part of the file, as this can be smaller. When providing the value for
- extra_headers
Optional[Dict[str, Optional[str]]]- Extra headers that will be included in the HTTP request.
This function returns a value of type UploadedPart.
Chunk has been uploaded successfully.
Abort an upload session and discard all data uploaded.
This cannot be reversed.
The actual endpoint URL is returned by the Create upload session
and Get upload session endpoints.
This operation is performed by calling function delete_file_upload_session_by_url.
See the endpoint docs at API Reference.
client.chunked_uploads.delete_file_upload_session_by_url(abort_url)- url
str- URL of deleteFileUploadSessionById method
- extra_headers
Optional[Dict[str, Optional[str]]]- Extra headers that will be included in the HTTP request.
This function returns a value of type None.
A blank response is returned if the session was successfully aborted.
Abort an upload session and discard all data uploaded.
This cannot be reversed.
The actual endpoint URL is returned by the Create upload session
and Get upload session endpoints.
This operation is performed by calling function delete_file_upload_session_by_id.
See the endpoint docs at API Reference.
client.chunked_uploads.delete_file_upload_session_by_id(upload_session_id)- upload_session_id
str- The ID of the upload session. Example: "D5E3F7A"
- extra_headers
Optional[Dict[str, Optional[str]]]- Extra headers that will be included in the HTTP request.
This function returns a value of type None.
A blank response is returned if the session was successfully aborted.
Return a list of the chunks uploaded to the upload session so far.
The actual endpoint URL is returned by the Create upload session
and Get upload session endpoints.
This operation is performed by calling function get_file_upload_session_parts_by_url.
See the endpoint docs at API Reference.
client.chunked_uploads.get_file_upload_session_parts_by_url(list_parts_url)- url
str- URL of getFileUploadSessionParts method
- offset
Optional[int]- The offset of the item at which to begin the response. Queries with offset parameter value exceeding 10000 will be rejected with a 400 response.
- limit
Optional[int]- The maximum number of items to return per page.
- extra_headers
Optional[Dict[str, Optional[str]]]- Extra headers that will be included in the HTTP request.
This function returns a value of type UploadParts.
Returns a list of parts that have been uploaded.
Return a list of the chunks uploaded to the upload session so far.
The actual endpoint URL is returned by the Create upload session
and Get upload session endpoints.
This operation is performed by calling function get_file_upload_session_parts.
See the endpoint docs at API Reference.
client.chunked_uploads.get_file_upload_session_parts(upload_session_id)- upload_session_id
str- The ID of the upload session. Example: "D5E3F7A"
- offset
Optional[int]- The offset of the item at which to begin the response. Queries with offset parameter value exceeding 10000 will be rejected with a 400 response.
- limit
Optional[int]- The maximum number of items to return per page.
- extra_headers
Optional[Dict[str, Optional[str]]]- Extra headers that will be included in the HTTP request.
This function returns a value of type UploadParts.
Returns a list of parts that have been uploaded.
Close an upload session and create a file from the uploaded chunks.
The actual endpoint URL is returned by the Create upload session
and Get upload session endpoints.
This operation is performed by calling function create_file_upload_session_commit_by_url.
See the endpoint docs at API Reference.
client.chunked_uploads.create_file_upload_session_commit_by_url(
commit_url, parts, digest
)- url
str- URL of createFileUploadSessionCommit method
- parts
List[UploadPart]- The list details for the uploaded parts.
- digest
str- The [RFC3230][1] 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]: https://tools.ietf.org/html/rfc3230
- The [RFC3230][1] message digest of the whole file. Only SHA1 is supported. The SHA1 digest must be Base64 encoded. The format of this header is as
- if_match
Optional[str]- Ensures this item hasn't recently changed before making changes. Pass in the item's last observed
etagvalue into this header and the endpoint will fail with a412 Precondition Failedif it has changed since.
- Ensures this item hasn't recently changed before making changes. Pass in the item's last observed
- if_none_match
Optional[str]- Ensures an item is only returned if it has changed. Pass in the item's last observed
etagvalue into this header and the endpoint will fail with a304 Not Modifiedif the item has not changed since.
- Ensures an item is only returned if it has changed. Pass in the item's last observed
- extra_headers
Optional[Dict[str, Optional[str]]]- Extra headers that will be included in the HTTP request.
This function returns a value of type Optional[Files].
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.
Close an upload session and create a file from the uploaded chunks.
The actual endpoint URL is returned by the Create upload session
and Get upload session endpoints.
This operation is performed by calling function create_file_upload_session_commit.
See the endpoint docs at API Reference.
client.chunked_uploads.create_file_upload_session_commit(
upload_session_id, parts, digest
)- upload_session_id
str- The ID of the upload session. Example: "D5E3F7A"
- parts
List[UploadPart]- The list details for the uploaded parts.
- digest
str- The [RFC3230][1] 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]: https://tools.ietf.org/html/rfc3230
- The [RFC3230][1] message digest of the whole file. Only SHA1 is supported. The SHA1 digest must be Base64 encoded. The format of this header is as
- if_match
Optional[str]- Ensures this item hasn't recently changed before making changes. Pass in the item's last observed
etagvalue into this header and the endpoint will fail with a412 Precondition Failedif it has changed since.
- Ensures this item hasn't recently changed before making changes. Pass in the item's last observed
- if_none_match
Optional[str]- Ensures an item is only returned if it has changed. Pass in the item's last observed
etagvalue into this header and the endpoint will fail with a304 Not Modifiedif the item has not changed since.
- Ensures an item is only returned if it has changed. Pass in the item's last observed
- extra_headers
Optional[Dict[str, Optional[str]]]- Extra headers that will be included in the HTTP request.
This function returns a value of type Optional[Files].
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.
Starts the process of chunk uploading a big file. Should return a File object representing uploaded file.
This operation is performed by calling function upload_big_file.
client.chunked_uploads.upload_big_file(
file_byte_stream, file_name, file_size, parent_folder_id
)- file
ByteStream- The stream of the file to upload.
- file_name
str- The name of the file, which will be used for storage in Box.
- file_size
int- The total size of the file for the chunked upload in bytes.
- parent_folder_id
str- The ID of the folder where the file should be uploaded.
This function returns a value of type FileFull.