Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

b2cloud

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

b2cloud

Module for interacting with back blaze b2cloud api

  • 0.5.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-80%
Maintainers
1
Weekly downloads
 
Created
Source

B2Cloud

Circle CI

A module for interacting with Back Blaze B2Cloud

Configuration

In ~/.b2cloud.json place your credentials

i.e. { "accountId": "", "applicationKey": "" }

Helpers

  • function getBucketByName(bucketName, callback)
    • Retreives a bucket object by its name, rather than by bucketId
  • function uploadFile(filePath, bucketName, callback)
    • Uploads a file
  • function downloadFile(name, bucketName, savePath, range, callback)

Please note this is being actively worked on and will soon support all API operations as listed here:

https://www.backblaze.com/b2/docs/

I also will be adding helpers methods such as uploadFile, getBucketByName to make it easier to use

Documentation

All methods can use promises or callbacks

Installation

npm install b2cloud

Setup a file .b2cloud in your home folder. Setup like this:,

{
        "accountId": "",
        "applicationKey": ""
}
Usage Example:
    var b2cloud = require('b2cloud');

    return b2cloud.authorize.getBasicAuth().then(function(auth) {
        console.log('authenticated', auth);

    });

Classes

Authorize
Bucket
File

Authorize

Kind: global class

new Authorize(cache)

ParamType
cacheobject

authorize.getBasicAuth([callback]) ⇒ object

Fetches an authenticated session for interacting with b2cloud.

Kind: instance method of Authorize Returns: object - auth Returns an authenticated session

ParamType
[callback]function

Bucket

Kind: global class

new Bucket(cache)

ParamTypeDescription
cacheobjectObject used for caching requests.

bucket.createBucket(name, type, [callback]) ⇒ object

Creates a bucket in the b2cloud

Kind: instance method of Bucket Returns: object - The response from b2_create_bucket

ParamTypeDescription
namestringName of the bucket
typestringEither allPublic or allPrivate, sets the bucket to public or private access.
[callback]functionThe optional callback

bucket.deleteBucket(bucketId, [callback]) ⇒ object

Deletes a bucket from the b2cloud

Kind: instance method of Bucket Returns: object - The response from b2_create_bucket

ParamTypeDescription
bucketIdstringBucketId as recieved from listBuckets or getBucketByName
[callback]functionThe optional callback

bucket.listBuckets([callback]) ⇒ object

Lists all buckets you have created.

Kind: instance method of Bucket Returns: object - The response from b2_list_buckets

ParamTypeDescription
[callback]functionThe optional callback.

bucket.getBucketByName(name, [callback]) ⇒ object

Helper function that returns a bucket object by its name.

Kind: instance method of Bucket Returns: object - The response from b2_list_buckets

ParamTypeDescription
namestringThe name of the bucket.
[callback]functionAn optional callback

bucket.listBucketFiles(name, [startFileName], [maxFileCount], [callback]) ⇒ object

Lists all files inside of a bucket.

Kind: instance method of Bucket Returns: object - The response from b2_list_file_names See: https://www.backblaze.com/b2/docs/b2_list_file_names.html

ParamTypeDescription
namestringThe name of the bucket
[startFileName]stringIf the number of files exceeds the response limit, this will set which file to start listing from
[maxFileCount]numberMax number of files to return, cannot be greater than 1000
[callback]functionThe optional callback

File

Kind: global class

new File(cache)

Class constructor, instantiates auth and bucket classes

ParamTypeDescription
cacheobjectCache object shared amongst classes.

file.getUploadUrl(bucketName, [callback]) ⇒ object

Gets the uploadUrl for uploadinga file to b2cloud

Kind: instance method of File Returns: object - - The response from b2_get_upload_url

ParamTypeDescription
bucketNamestringName of the bucket to get a uploadUrl for
[callback]functionOptional callback

file.uploadFile(filePath, bucketName, [callback]) ⇒ object

Helper function that automatically generates the uploadUrl, hashes the file and uploads it to b2cloud.

Kind: instance method of File Returns: object - - The newly created b2cloud object.

ParamTypeDescription
filePathstringThe file path to the file you want to upload
bucketNamestringThe bucke to upload the file to.
[callback]functionThe optional callback

file.downloadFile(name, bucketName, savePath, range, [callback]) ⇒ Promsise

Downloads a file from b2cloud

Kind: instance method of File Returns: Promsise - That resolves if the file is downloaded succesfully, otherwise rejects. See: https://www.backblaze.com/b2/docs/b2_download_file_by_name.html

ParamTypeDescription
namestringName of the file to download
bucketNamestringBucket the file resides in
savePathstringPath to save the file to
rangeobjectThe range object used to fetch only a byte range, byte range is inclusive
range.startnumberThe start byte to download
range.endnumberThe end byte to download
[callback]functionThe optional callback

file.deleteFileVersion(fileName, fileId, [callback]) ⇒ *

Deletes a specific version of a file from b2cloud.

Kind: instance method of File

ParamTypeDescription
fileNamestringName of the file to delete.
fileIdstringThe unique fileid to delete
[callback]functionOptional callback

Keywords

FAQs

Package last updated on 31 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc