Drive > Files > File/Directory > Upload > Session

Start session

This call creates a new upload session. <br/> Upload session allows you to upload a single file in one or more requests (chunks). It is the only way to upload a file larger than 1GB. <br/><note> The maximum size per chunk request is 1GB. </note> <br/><note> When a session is started, it can be used for a maximum of 4 hours. </note> <br/><note> To upload a chunk, you must use the ‘upload_url’ returned from this session opening call : <a href="#">upload/session/start</a>. </note><br/><note> Finally, when all the data have been sent, you should call <a href="./{session_token}/finish">upload/session/finish</a> to close the session and save the file in kDrive. </note> <br/><note> If your file is small (<100MB) we recommend you to use the <a href="../../upload">direct upload route</a> to avoid multiple requests.</note>

post/3/drive/{drive_id}/upload/session/start

Path parameters

drive_idinteger required

Drive identifier

Query parameters

withstring

Optional : Allows loading additional data about a resource, which may include related resources.

Headers

If-Matchstring nullable

Specify a ETag (Entity tag) who is the identifier for a specific version of file.

Example:9e22d98e554fe8df

Request body

conflict'error' | 'rename' | 'version'

Select what to do when a file with the same name already exists. The default conflict mode is error.<li><small><ul><strong>error</strong> : An error is returned without creating the file/session.</ul><ul><strong>rename</strong> : Rename the new file with an available name (ex. file.txt to file(3).txt).</ul><ul><strong>version</strong> : Replace the content of the existing file (create a new version of the file).</ul></small></li>

created_atinteger

Override the creation date metadata of the new file.<note>The value of this field will be capped at 24h from the current time.</note>

directory_idinteger

The directory destination root of the new file. Must be a directory. <note>If the identifier is unknown you can use only <strong>directory_path</strong>.</note> <note>You can get your root private folder ID from <a href='/docs/api/get/3/drive/{drive_id}/files/{file_id}/files'>3/drive/{drive_id}/files/{file_id}/files</a>. <note>Required without <strong>directory_path</strong></note>

directory_pathstring nullable

The destination path of the new file. If the <strong> directory_id</strong> is provided the directory path is used as a relative path, otherwise it will be used as an absolute path. The destination should be a directory. <note>If the directory path does not exist, folders are created automatically.</note> <note>The path is a destination path, the file name should not be provided at the end.</note> <note>Required without <strong>directory_id</strong>.</note>

file_idinteger

File identifier of uploaded file. <note>This is an alternative to replace a file by its identifier, if this mode is used <strong>file_name</strong>, <strong>directory_id</strong>, <strong>conflict</strong> and <strong>directory_path</strong> params are automatically computed and cannot be provided.</note> <note>If you don't know the identifier, or you want to upload a new file, you should provide a filename and a directory destination.</note>

file_namestring

The name of the file to create. <note>Slashes will be replaced by colons.</note> <note>Maximum bytes size is 255</note>

last_modified_atinteger

Override the update date metadata of the new file.<note>The value of this field will be capped at 24h from the current time.</note>

total_chunksinteger required

The total number of chunks attached to the session.

total_sizeinteger required

Expected total size of the file to upload. If the uploaded content does not match this size, an error will be returned.<note>the unit of size is defined in Bytes.</note>

Example request

{
  "conflict": "version",
  "directory_path": "/Directory/SubDirectory",
  "file_name": "file.txt"
}

Response

OK

result'success' | 'error' | 'asynchronous' required

Result of the HTTP request

data91ac10ffUploadSessionFeedback — unresolved $ref

Changes

No recorded changes to this endpoint across all 1 revision of this API.