b2_finish_large_file
    • Dark
      Light

    b2_finish_large_file

    • Dark
      Light

    Article Summary

    Post
    /b2api/v3/b2_finish_large_file

    Converts the parts that have been uploaded into a single B2 file

    After you have uploaded the parts, use this call to combine the uploaded parts into one large file.

    It may be that the call to finish a large file succeeds, but you don't know it because the request timed out, or the connection was broken. In that case, retrying will result in a 400 Bad Request response because the file is already finished. If that happens, we recommend calling b2_get_file_info to see if the file is there. If the file is there, you can count the upload as a success.

    API Versions

    v1: Application keys (July 26, 2018)

    Incompatible change: After calling b2_authorize_account with an application key that does not have the right permissions, this call will return a 401 Unauthorized.

    v1: Original release (September 22, 2015)


    PLEASE NOTE:

    This API endpoint can be called using a GET request by converting the parameters in the request body to query parameters.

    Header parameters
    Authorization
    stringRequired

    An account authorization token, obtained from b2_authorize_account.
    The token must have the writeFiles capability.

    Body parameters
    object
    fileId
    string Required

    The ID returned by b2_start_large_file.

    Example4_zb2f6f21365e1d29f6c580f18_f20150c1fda5f4c8d_d20180919_m215912_c002_v0001110_t0050
    partSha1Array
    Array of stringRequired

    A JSON array of hex SHA1 checksums of the parts of the large file. This is a double-check that the right parts were uploaded in the right order, and that none were missed. Note that the part numbers start at 1, and the SHA1 of the part 1 is the first string in the array, at index 0.


    ["40d2b810f4b3978444b98d44a01cbc2680432726","956a86f77f2fd6181fcec963d3244689b720d845"]

    Example[ "40d2b810f4b3978444b98d44a01cbc2680432726", "956a86f77f2fd6181fcec963d3244689b720d845" ]
    string
    Valid values[ "An SHA1 checksum" ]
    Responses
    200

    The request succeeded.


    The response headers include the Content-Type that was specified when the file was uploaded. They also include the X-Bz-FileName and X-Bz-Content-Sha1 headers, plus X-Bz-Info-* headers for any custom file info that was provided with the upload. The X-Bz-FileName uses percent-encoding, as if it were a URL parameter.

    Expand All
    object
    accountId
    string

    The account that owns the file.

    ExampleYOUR_ACCOUNT_ID
    action
    string

    One of "start", "upload", "hide", "folder", or other values added in the future. "upload" means a file that was uploaded to B2 Cloud Storage. "start" means that a large file has been started, but not finished or canceled. "hide" means a file version marking the file as hidden, so that it will not show up in b2_list_file_names. "folder" is used to indicate a virtual folder when listing files.

    Exampleupload
    bucketId
    string

    The bucket that the file is in.

    Examplee73ede9c9c8412db49f60715
    contentLength
    integer

    The number of bytes stored in the file. Only useful when the action is "upload". Always 0 when the action is "start", "hide", or "folder".

    Example208158542
    contentSha1
    string

    The SHA1 of the bytes stored in the file as a 40-digit hex string. Large files do not have SHA1 checksums, and the value is "none". The value is null when the action is "hide" or "folder".

    Examplenone
    contentMd5
    string

    The MD5 of the bytes stored in the file as a 32-digit hex string. Not all files have an MD5 checksum, so this field is optional, and set to null for files that do not have one. Large files do not have MD5 checksums, and the value is null. The value is also null when the action is "hide" or "folder".

    Example142be8357f26eda2ec6775cce257753b
    contentType
    string

    When the action is "upload" or "start", the MIME type of the file, as specified when the file was uploaded. For "hide" action, always "application/x-bz-hide-marker". For "folder" action, always null.

    Exampleb2/x-auto
    fileId
    string

    The unique identifier for this version of this file. Used with b2_get_file_info, b2_download_file_by_id, and b2_delete_file_version. The value is null when for action "folder".

    Example4_ze73ede9c9c8412db49f60715_f200b4e93fbae6252_d20150824_m224353_c900_v8881000_t0001
    fileInfo
    object

    The custom information that was uploaded with the file. This is a JSON object, holding the name/value pairs that were uploaded with the file.

    Example{ "author": "unknown" }
    fileName
    string

    The name of this file, which can be used with b2_download_file_by_name.

    Examplebigfile.dat
    fileRetention
    object

    The Object Lock retention settings for this file, if any. This field is filtered based on application key capabilities; the readFileRetentions capability is required to access the value. See Object Lock for more details on response structure. This field is omitted when the action is "hide" or "folder".

    Example{ "isClientAuthorizedToRead": true, "value": { "mode": null, "retainUntilTimestamp": null } }
    isClientAuthorizedToRead
    boolean
    value
    object
    mode
    string
    retainUntilTimestamp
    integer
    legalHold
    object

    The Object Lock legal hold status for this file, if any. This field is filtered based on application key capabilities; the readFileLegalHolds capability is required to access the value. See Object Lock for more details on response structure. This field is omitted when the action is "hide" or "folder".

    Example{ "isClientAuthorizedToRead": true, "value": null }
    isClientAuthorizedToRead
    boolean
    value
    string
    replicationStatus
    string

    The Replication Status for this file, if any. This will show either PENDING, COMPLETED, FAILED, or REPLICA For details see Cloud Replication


    This field is omitted when the file is not part of a replication rule.

    ExamplePENDING
    serverSideEncryption
    object

    When the file is encrypted with Server-Side Encryption, the mode ("SSE-B2" or "SSE-C") and algorithm used to encrypt the data. If the file is not encrypted with Server-Side Encryption, then both mode and algorithm will be null. This field is omitted when the action is "hide" or "folder".

    Example{ "algorithm": null, "mode": null }
    mode
    string
    algorithm
    string
    uploadTimestamp
    integer

    This is a UTC time when this file was uploaded. It is a base 10 number of milliseconds since midnight, January 1, 1970 UTC. This fits in a 64 bit integer such as the type "long" in the programming language Java. It is intended to be compatible with Java's time long. For example, it can be passed directly into the java call Date.setTime(long time). Always 0 when the action is "folder".

    Example1460162909000
    400
    statuscodedescription
    400bad_bucket_idThe requested bucket ID does not match an existing bucket.
    400bad_requestThe request had the wrong fields or illegal values. The message returned with the error will describe the problem.
    object
    status
    integer

    The numeric HTTP status code. Always matches the status in the HTTP response.

    Example400
    code
    string

    A single-identifier code that identifies the error.

    Exampleinvalid_bucket_name
    message
    string

    A human-readable message, in English, saying what went wrong.

    Examplebucket name is too long
    401
    statuscodedescription
    401bad_auth_tokenThe auth token used is not valid. Call b2_authorize_account again to either get a new one, or an error message describing the problem.
    401expired_auth_tokenThe auth token used has expired. Call b2_authorize_account again to get a new one.
    401unauthorizedThe auth token used is valid, but does not authorize this call with these parameters. The capabilities of an auth token are determined by the application key used with b2_authorize_account.

    Was this article helpful?