b2_start_large_file
    • Dark
      Light

    b2_start_large_file

    • Dark
      Light

    Article Summary

    Post
    /b2api/v3/b2_start_large_file

    Prepares parts of a large file for uploading

    Warning
    Do not include Protected Health Information (PHI) or Personally Identifiable Information (PII) in bucket names; object, file, or folder names; or other metadata. This metadata is not encrypted in a way that meets Health Insurance Portability and Accountability Act (HIPAA) protection requirements for PHI/PII data, and it is not generally encrypted in client-side encryption architectures.

    The file name and file info must fit within a 7,000 byte limit. For files that are uploaded with Server-Side Encryption and/or to Object Lock-enabled buckets, the size limit is reduced to 2,048 bytes. See Files for further details about HTTP header size limit.

    API Versions

    v2: Consistent file structures (Sept 13, 2018)

    Now returns action ("start"), contentLength (0), and contentSha1 ("none").

    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
    Expand All
    object
    bucketId
    string Required

    The ID of the bucket that the file will go in.

    Example4a48fe8875c6214145260818
    fileName
    string Required

    The name of the file. See Files for requirements on file names.

    Example
    contentType
    string Required

    The MIME type of the content of the file, which will be returned in the Content-Type header when downloading the file. Use the Content-Type b2/x-auto to automatically set the stored Content-Type post upload. In the case where a file extension is absent or the lookup fails, the Content-Type is set to application/octet-stream. The Content-Type mappings can be perused here.

    ExampleFILE_ID
    customUploadTimestamp
    string

    If this is present, B2 will use it as the value of the upload timestamp. The value should be a base 10 number that represents a UTC time when the original source file was uploaded. It is a base 10 number of milliseconds since midnight, January 1st, 1970 UTC. This fits in a 64-bit integer, such as the type long in Java, and so it can be passed directly into the Java call Date.setTime(long time). The value must not use a date that is set to a time in the future. If the value is null, it will be ignored.


    NOTE: If you need to use this feature, please contact Backblaze support to have the feature enabled on your account.

    Example
    fileInfo
    object

    A JSON object holding the name/value pairs for the custom file info.


    If the original source of the file being uploaded has a last modified time concept, Backblaze recommends using src_last_modified_millis as the name, and a string holding the base 10 number 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).


    If the caller knows the SHA1 of the entire large file being uploaded, Backblaze recommends using large_file_sha1 as the name, and a 40 byte hex string representing the SHA1.


    To set the Content-Disposition header provided when the file is downloaded, set 'b2-content-disposition'. (It may be overridden by a value given in the download request.) The value must match the grammar specified in RFC 6266. Parameter continuations are not supported. 'Extended-value's are supported for charset 'UTF-8' (case-insensitive) when the language is empty. Note that this file info will not be included in downloads as a x-bz-info-b2-content-disposition header. Instead, it (or the value specified in a request) will be in the Content-Disposition header.


    To set the Content-Language header provided when the file is downloaded, set 'b2-content-language'. The value must match the grammar specified in RFC 2616. Note that this file info will not be included in downloads as a x-bz-info-b2-content-language header. Instead, it (or the value specified in a request) will be in the Content-Language header.


    To set the Expires header provided when the file is downloaded, set 'b2-expires'. The value must match the grammar specified in RFC 2616. Note that this file info will not be included in downloads as a x-bz-info-b2-expires header. Instead, it (or the value specified in a request) will be in the Expires header.


    To set the Cache-Control header provided when the file is downloaded, set 'b2-cache-control'. The value must match the grammar specified in RFC 2616. Note that this file info will not be included in downloads as a x-bz-info-b2-cache-control header. Instead, it (or the value specified in a request) will be in the Cache-Control header.


    To set the Content-Encoding header provided when the file is downloaded, set 'b2-content-encoding'. The value must match the grammar specified in RFC 2616. Note that this file info will not be included in downloads as a x-bz-info-b2-content-encoding header. Instead, it (or the value specified in a request) will be in the Content-Encoding header.

    Example{ "src_last_modified_millis": "1452802803026", "large_file_sha1": "a3195dc1e7b46a2ff5da4b3c179175b75671e80d", "color": "blue" }
    fileRetention
    object

    If present, specifies the Object Lock retention settings for the file. Setting the value requires the writeFileRetentions capability and that the bucket is Object Lock-enabled. See Object Lock for details.

    Example{ "mode": "compliance", "retainUntilTimestamp": "1628942493000" }
    mode
    string
    Valid values[ "compliance", "governance" ]
    retainUntilTimestamp
    integer
    legalHold
    string

    If present, specifies the Object Lock legal hold status for the file. Setting the value requires the writeFileLegalHolds capability and that the bucket is Object Lock-enabled. Object Lock for details.

    Exampleon
    serverSideEncryption
    object

    If present, specifies the parameters for Backblaze B2 to use for encrypting the uploaded data before storing the file using Server-Side Encryption. See Server-Side Encryption for details.

    Example{ "mode": "SSE-C", "algorithm": "AES256", "customerKey": "<base64-encoded AES-256 encryption key>", "customerKeyMd5": "<base64-encoded MD5 digest of the key>" }
    mode
    string
    algorithm
    string
    customerKey
    string
    customerKeyMd5
    string
    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.

    Examplestart
    bucketId
    string

    The bucket that the file is in.

    Exampleb2f6f21365e1d29f6c580f18
    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".

    Example0
    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".

    Exampledc724af18fbdd4e59189f5fe768a5f8311527050
    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.

    Exampleapplication/x-bz-hide-marker
    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_zb2f6f21365e1d29f6c580f18_f20150c1fda5f4c8d_d20180919_m215912_c002_v0001110_t0050
    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{ "src_last_modified_millis": "1452802803026", "large_file_sha1": "a3195dc1e7b46a2ff5da4b3c179175b75671e80d", "color": "blue" }
    fileName
    string

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

    Example~/Downloads/512MB.zip
    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": "off" }
    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 }
    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".

    Example1537394352000
    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.
    400custom_timestamp_invalidThe request has an invalid custom upload timestamp.
    400custom_timestamp_not_allowedThe account is not allowed to specify a custom upload timestamp.
    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.
    415
    statuscodedescription
    415unsupported_media_typeThe requested Content-Type is not valid

    Was this article helpful?