Upload to this file on B2.
This works by loading chunks of the stream, upto B2.partSize
,
into memory. If the stream has less than or equal to that many bytes, a
single-part upload will be attempted.
Otherwise, a multi-part upload will be attempted by loading up-to
b2.partSize
bytes of the stream into memory at a time.
const file = bucket.file("example");
const stream = file.createWriteStream();
stream.on("error", (err) => {
// handle the error
// note that retries are automatically attempted before errors are
// thrown for most potentially recoverable errors, as per the B2 docs.
})
stream.on("finish", (err) => {
// upload done, the file instance has been updated to reflect this
})
res.body.pipe(stream);
When getting a file's ids by its fileName
, this is a Class C transaction
See https://www.backblaze.com/b2/cloud-storage-pricing.html
Gets file data by fileId or fileName.
When stating a file without its fileId
, this is a Class C transaction
See https://www.backblaze.com/b2/cloud-storage-pricing.html
Generated using TypeDoc
Download this file from B2.
const file = bucket.file("text.txt"); file.createReadStream();