Initializes a new client to interact with Backblaze B2.
Dictionary with connection options.
Returns an instance of the client object, to interact with the cloud provider directly
Returns the name of the provider
Specifies for how long (in ms) to keep BucketId data in cache. Set to 0 to disable caching. Default is 15 minutes.
Performs authorization
Promise that resolves once the client is authorized
Returns the bucketId property for a given bucket name, as most B2 methods require a bucket's ID.
The result is cached in memory for a certain amount of time configured with BackblazeB2Provider.bucketIdCacheDuration
(default: 15 minutes), and up to 100 IDs.
Name of the bucket
Promise that resolves with the bucketId
Returns the fileId property for a given file name, as some B2 methods require a file's ID
ID of the bucket
Name of the file
Promise that resolves with the fileId
Create a container ("bucket") on the server.
Name of the container
Dictionary with options for creating the container, including the access level
Promise that resolves once the container has been created. The promise doesn't contain any meaningful return value.
Removes a container from the server
Name of the container
Promise that resolves once the container has been removed
Removes an object from the server
Name of the container
Path of the object, inside the container
Promise that resolves once the object has been removed
Create a container ("bucket") on the server if it doesn't already exist.
Name of the container
Dictionary with options for creating the container, including the access level
Promise that resolves once the container has been created
Requests an object from the server. The method returns a Promise that resolves to a Readable Stream containing the data.
Name of the container
Path of the object, inside the container
Readable Stream containing the object's data
Requests an object from the server. The method returns a Promise that resolves to a Buffer object containing the data from the server.
Name of the container
Path of the object, inside the container
Buffer containing the object's data
Requests an object from the server. The method returns a Promise that resolves to a string containing the data from the server.
Name of the container
Path of the object, inside the container
Optional encoding for the string; defaults to utf8
String containing the object's data
Check if a container exists.
Name of the container
Promises that resolves with a boolean indicating if the container exists.
Lists all containers belonging to the user
Promise that resolves with an array of all the containers
Returns a list of objects with a given prefix (folder). The list is not recursive, so prefixes (folders) are returned as such.
Name of the container
Prefix (folder) inside which to list objects
List of elements returned by the server
Returns a URL that clients (e.g. browsers) can use to request an object from the server with a GET request, even if the object is private.
Backblaze B2 currently does not support this API, and calling this method will always throw an error. Sorry!
Name of the container
Path of the object, inside the container
Expiry time of the URL, in seconds (default: 1 day)
Promise that resolves with the pre-signed URL for GET requests
Returns a URL that clients (e.g. browsers) can use for PUT operations on an object in the server, even if the object is private.
Backblaze B2 currently does not support this API, and calling this method will always throw an error. Sorry!
Name of the container
Path where to store the object, inside the container
Key-value pair of options used by providers, including the metadata
dictionary
Expiry time of the URL, in seconds (default: 1 day)
Promise that resolves with the pre-signed URL for GET requests
Uploads a stream to the object storage server.
The Backblaze B2 APIs have relatively poor support for streams, as it requires the size of the data to be sent at the beginning of the request. As a consequence, this method will upload the file using a different API based on the input data:
data
is a Buffer or a string, and when data
is a Stream and either the options.length
argument is specified, or data.byteLength
is defined (all data is loaded in memory before being sent to the server in this case).data
is a Stream and the length can't be known beforehand, if the data is longer than B2Upload.chunkSize
(default: 9MB; minimum: 5MB) the method will use B2's large files APIs. With those, it's possible to chunk the file into many chunks and upload them separately, thus it's not necessary to load the entire Stream in memory. However, this way of uploading files requires many more network calls, and could be significantly slower. B2 supports up to 1,000 chunks per object, so using 9MB chunks (the default value for B2Upload.chunkSize
), maximum file size is 90GB.Notes on the metadata:
Content-Type
header is always supported and used as-isX-Bz-Info-
prefix (if your headers don't start with this prefix, it will be added automatically)Name of the container
Path where to store the object, inside the container
Object data or stream. Can be a Stream (Readable Stream), Buffer or string.
Key-value pair of options used by providers, including the metadata
dictionary. For the Backblaze B2 provider, this object contains the length
property too, which is useful when passing a stream as data object, as it might allow for faster uploads.
Promise that resolves once the object has been uploaded
Generated using TypeDoc
Client to interact with Backblaze B2 cloud storage.