npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

backblaze-b2-extended

v1.0.4

Published

Node.js Library for the Backblaze B2 Storage Service. Forked and extended from yakovkhalinsky's

Downloads

19

Readme

Backblaze B2 Node.js Library

npm version Build Status

This library uses promises, so all actions on a B2 instance return a promise in the following pattern

b2.instanceFunction(arg1, arg2).then(
    successFn(response) { ... },
    errorFn(err) { ... }
);

Status of project

See the CHANGELOG for a history of updates.

Contributing and Suggestions for Changes and Fixes

Contributions and questions are welcome. If you are looking for something to help with, please have a look at the ISSUES or add an issue if there is something you would like to see or fix.

Make sure you use the .editorconfig in your IDE/editor when writing code.

Pull Requests should include:

  • Updated example in README.md
  • Update exiting tests, or add new tests to cover code changes

If you are adding tests, add these to /test/unit. Make sure the test is named fooTest.js and is located in a similar folder to the node module that is being tested.

Always run npm test before you commit.

Upgrading from 0.9.x to 1.0.x

For this update, we've switched the back end HTTP request library from request to axios as it has better Promise and progress support built in. However, there are a couple changes that will break your code and ruin your day. Here are the changes:

  • The Promise resolution has a different data structure. Where previously, the request response data was the root object in the promise resolution (res), this data now resides in res.data.
  • In v0.9.12, we added request progress reporting via the third parameter to then(). Because we are no longer using the same promise library, this functionality has been removed. However, progress reporting is still available by passing a callback function into the b2.method() that you're calling. See the documentation below for details.
  • In v0.9.x, b2.downloadFileById() accepted a fileId parameter as a String or Number. As of 1.0.0, the first parameter is now expected to be a plain Object of arguments.

Usage

var B2 = require('backblaze-b2');

// All functions on the b2 instance return the response from the B2 API in the success callback
// i.e. b2.foo(...).then(function(b2JsonResponse) {})

// create b2 object instance
var b2 = new B2({
    accountId: 'accountId',
    applicationKey: 'applicationKey'
});

// authorize with provided credentials
b2.authorize();  // returns promise

// create bucket
b2.createBucket(
  bucketName,
  bucketType // one of `allPublic`, `allPrivate`
);  // returns promise

// delete bucket
b2.deleteBucket(bucketId);  // returns promise

// list buckets
b2.listBuckets();  // returns promise

// update bucket2
b2.updateBucket(bucketId, bucketType);  // returns promise

// get upload url
b2.getUploadUrl(bucketId);  // returns promise

// upload file
b2.uploadFile({
    uploadUrl: 'uploadUrl',
    uploadAuthToken: 'uploadAuthToken',
    filename: 'filename',
    mime: '', // optonal mime type, will default to 'b2/x-auto' if not provided
    data: 'data' // this is expecting a Buffer not an encoded string,
    info: {
        // optional info headers, prepended with X-Bz-Info- when sent, throws error if more than 10 keys set
        // valid characters should be a-z, A-Z and '-', all other characters will cause an error to be thrown
        key1: value
        key2: value
    },
    onUploadProgress: function(event) || null // progress monitoring
});  // returns promise

// list file names
b2.listFileNames({
    bucketId: 'bucketId',
    startFileName: 'startFileName',
    maxFileCount: 100,
    delimiter: '',
    prefix: ''
});  // returns promise

// list file versions
b2.listFileVersions({
    bucketId: 'bucketId',
    startFileName: 'startFileName',
    maxFileCount: 100
});  // returns promise

// hide file
b2.hideFile({
    bucketId: 'bucketId',
    fileName: 'fileName'
});  // returns promise

// get file info
b2.getFileInfo(fileId);  // returns promise

// download file by name
b2.downloadFileByName({
    bucketName: 'bucketName',
    fileName: 'fileName',
    onDownloadProgress: function(event) || null // progress monitoring
});  // returns promise

// download file by fileId
b2.downloadFileById({
  fileId: 'fileId',
  onDownloadProgress: function(event) || null // progress monitoring
});  // returns promise

// delete file version
b2.deleteFileVersion({
    fileId: 'fileId',
    fileName: 'fileName'
});  // returns promise

// start large file
b2.startLargeFile({
  bucketId: 'bucketId',
  fileName: 'fileName'
}) // returns promise

// get upload part url
b2.getUploadPartUrl({
  fileId: 'fileId'
}) // returns promise

// get upload part
b2.uploadPart({
  partNumber: 'partNumber', // A number from 1 to 10000
  uploadUrl: 'uploadUrl',
  uploadAuthToken: 'uploadAuthToken', // comes from getUploadPartUrl();
  data: Buffer // this is expecting a Buffer not an encoded string,
  onUploadProgress: function(event) || null // progress monitoring
}) // returns promise

// finish large file
b2.finishLargeFile({
  fileId: 'fileId',
  partSha1Array: [partSha1Array] // array of sha1 for each part
}) // returns promise

// cancel large file
b2.cancelLargeFile({
  fileId: 'fileId'
}) // returns promise

Authors

  • Yakov Khalinsky (@yakovkhalinsky)
  • Ivan Kalinin (@IvanKalinin) at Isolary
  • Brandon Patton (@crazyscience) at Isolary