Add File Information with the Native API
    • Dark
      Light

    Add File Information with the Native API

    • Dark
      Light

    Article Summary

    For all of the Backblaze API operations and their corresponding documentation, see API Documentation.

    You can add key/value pairs as custom file information. Each key is a UTF-8 string up to 50 bytes and can contain letters, numbers, and the following list of special characters:

    -

    ,

    _

    ,

    .

    `

    ~

    !

    #

    $

    %

    ^

    &

    *

    '

    |

    +

    Each key is converted into lowercase. Names that begin with "b2-" are reserved. There is an overall 7000-byte limit on the headers that are needed for file name and file information, unless the file is uploaded with server-side encryption in which case the limit is 2048 bytes.

    For names that do not start with "b2-," there is no limit on the size or content of the values other than the overall size limit.

    You provide the file information using the b2_upload_file call for regular files, and the b2_start_large_file call for large files. This is set when the file is uploaded and cannot be changed. The b2_get_file_info call returns the information about a file. The information is also returned in the HTTP headers when you download a file.

    If the original source of the file you are uploading has a last modified time concept, Backblaze recommends using src_last_modified_millis as the key and a string holding the base 10 number number of milliseconds since midnight, January 1, 1970 UTC as the value. 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 you are uploading a large file and if you know the SHA1 of the entire large file, Backblaze recommends using large_file_sha1 as the key, and a 40 byte hex string representing the SHA1 as the value.

    Exceptions

    Names that start with "b2-" must be in the list of defined "b2-" names and their values must be valid. Backblaze B2 Cloud Storage rejects any upload request with an unexpected "b2-" file info name. Backblaze B2 also rejects any upload with a "b2-" file info name whose value does not meet the specified format for that name.

    b2-content-disposition
    optional

    If this is present, Backblaze B2 uses it as the value of the 'Content-Disposition' header when the file is downloaded (unless it is overridden by a value that was 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.

    b2-content-language
    optional

    If this is present, B2 will use it as the value of the 'Content-Language' header when the file is downloaded (unless it's overridden by a value given in the download request). 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.

    b2-expires
    optional

    If this is present, B2 will use it as the value of the 'Expires' header when the file is downloaded (unless it's overridden by a value given in the download request). 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.

    b2-cache-control
    optional

    If this is present, B2 will use it as the value of the 'Cache-Control' header when the file is downloaded (unless it's overridden by a value given in the download request), and overriding the value defined at the bucket level. 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-cache-control header. Instead, it (or the value specified in a request) will be in the Cache-Control header.

    b2-content-encoding
    optional

    If this is present, B2 will use it as the value of the 'Content-Encoding' header when the file is downloaded (unless it's overridden by a value given in the download request). 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.


    Was this article helpful?