Source Code Bundles
Uploads one file to B2, returning its unique file ID.
The upload request is a POST. The file name and other parameters are in the request headers, and the file to be uploaded is the request body.
Request HTTP Headers
An upload authorization token, from
The name of the file, in percent-encoded UTF-8. For example, spaces should be replaced with %20. For more information, see Files for requirements on file names and String Encoding for how to encode strings.
The MIME type of the content of the file, which will
be returned in the
The number of bytes in the file being uploaded. Note that this
header is required; you cannot leave it out and just use chunked
The SHA1 checksum of the content of the file. B2 will check this
when the file is uploaded, to make sure that the file arrived
correctly. It will be returned in the
If the original source of the file being uploaded has a last modified time concept, Backblaze recommends using this spelling of one of your ten X-Bz-Info-* headers (see below). Using a standard spelling allows different B2 clients and the B2 web user interface to interoperate correctly. The value should be a base 10 number which represents a UTC time when the original source file was last modified. 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).
If this is present, B2 will use it as the value of the 'Content-Disposition' 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 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.
Up to 10 of these headers may be present. The
The following HTTP headers must not be included in the
The file name and file info must fit, along with the other necessary headers, within a 7,000 byte limit. This limit applies to the fully encoded HTTP header line, including the carriage-return and newline. See Files for further details about HTTP header size limit.
Request HTTP Message Body Parameters
There are no JSON parameters allowed. The file to be uploaded is the message body and is not encoded in any way. It is not URL encoded. It is not MIME encoded.
Response HTTP Status 200
File successfully uploaded. The JSON response will contain:
The name of this file, which can be used with
Your account ID.
The bucket that the file is in.
The number of bytes stored in the file.
The SHA1 of the bytes stored in the file.
The MIME type of the file.
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.
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).
File not uploaded.
If possible the server will return a JSON error structure. Errors include: