Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jamesloper/easy-backblaze
The absolute simplest way possible to make Backblaze B2 API calls.
https://github.com/jamesloper/easy-backblaze
backblaze backblaze-b2
Last synced: 27 days ago
JSON representation
The absolute simplest way possible to make Backblaze B2 API calls.
- Host: GitHub
- URL: https://github.com/jamesloper/easy-backblaze
- Owner: jamesloper
- Created: 2017-05-27T00:06:04.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-08-27T22:18:27.000Z (over 7 years ago)
- Last Synced: 2024-11-14T13:13:06.972Z (about 2 months ago)
- Topics: backblaze, backblaze-b2
- Language: JavaScript
- Size: 20.5 KB
- Stars: 12
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
`npm install --save easy-backblaze`
Easy Backblaze is a powerful, yet simple and lightweight re-imagination of the Backblaze API. Upload a file in one call, just like in S3! Because of the depth and complexity of simply uploading, for now, this package will focus only on uploading a file. It will retry after encountering 429 (Too Many Requests), 408 (Request Timeout), 500 (Internal Error) and 503 (Service Unavailable) errors.
``` javascript
var B2 = require('easy-backblaze');
var b2 = new B2('account_id', 'application_key');b2.uploadFile('/var/tmp/test.mp4', {
name: 'swiggity-swooty.mp4', // Optional, renames file
bucket: 'swooty', // Optional, defaults to first bucket
}, function(err, res) {
console.log('Done!', err, res);
});// res = https://f001.backblazeb2.com/file/swooty/swiggity-swooty.mp4
```## Get Progress Updates
``` javascript
var client = b2.uploadFile('/var/tmp/test.mp4', function(err, res) {
console.log('Done!', err, res);
});client.on('progress', function(progress) {
// Every time 512 KB finish uploading
console.log('Progress:', progress);
});
```## AES-256 Encryption
To upload a file and encrypt it, just add a **password**:
``` javascript
b2.uploadFile('/var/tmp/test.mp4', {
password: 'ggf96fjo',
name: 'secretFileName.mp4',
}, function(err, res) {
console.log('Done!', err, res);
});
```To decrypt, download and pipe the stream through any old compatible decipher:
``` javascript
var decipher = crypto.createDecipher('aes-256-ctr', 'ggf96fjo');
var input = fs.createReadStream('test.mp4');
var output = fs.createWriteStream('output.mp4');
input.pipe(decipher).pipe(output);
```## Additional Options
An additional **options** argument can be used to specify a default bucket for uploads.
``` javascript
var b2 = new B2('account_id', 'application_key', {bucket: 'swooty'});
b2.uploadFile('/var/tmp/test.mp4', function(err, res) {
console.log('Done!', err, res);
});
```> If you appreciate the work that went into this, donate to 15BHA6gPYszTfsbDHUag4nu6WZiQPkDoUL