b2_upload_fileUploads one file to B2, returning its unique file ID. RequestThe 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. URL Path
Use the https://pod-000-1007-13.backblaze.com/b2api/v2/b2_upload_file/4a48fe8875c6214145260818/c001_v0001007_t0042 Request HTTP HeadersAuthorization required
An upload authorization token, from X-Bz-File-Name required 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. Content-Type required
The MIME type of the content of the file, which will
be returned in the Content-Length required
The number of bytes in the file being uploaded. Note that this
header is required; you cannot leave it out and just use chunked
encoding.
X-Bz-Content-Sha1 required
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 X-Bz-Info-src_last_modified_millis optional 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). X-Bz-Info-b2-content-disposition optional 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. X-Bz-Info-* optional
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 ParametersThere 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. ResponseResponse HTTP Status 200File successfully uploaded. The JSON response will contain the standard file information. For uploaded files, the action is always "upload". accountId The account that owns the file. action
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 bucketId The bucket that the file is in. contentLength 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". contentSha1 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". contentType 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. fileId
The unique identifier for this version of this file.
Used with fileInfo 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. fileName
The name of this file, which can be used with
uploadTimestamp 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).
Response Errors
File not uploaded.
If possible the server will return a JSON error structure. Errors include:
Some errors returned mean that you must call
API Versionsv1: 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)Sample CodeCode
Output
Code
Output
Code
Output
Code
Output
Code
Output
Code
Output
Code
Output
|