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

github.com/emilhakobian/go-backblaze

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/emilhakobian/go-backblaze

  • v0.0.0-20210718214640-b251831b1e36
  • Source
  • Go
  • Socket score

Version published
Created
Source

go-backblaze

GoDoc Build Status

A golang client for Backblaze's B2 storage

Usage

Some simple examples to get you started. Errors are ommitted for brevity

Import the API package

import "gopkg.in/emilhakobian/go-backblaze.v0"

Create an API client

b2, _ := backblaze.NewB2(backblaze.Credentials{
  AccountID:      accountID,
  ApplicationKey: applicationKey,
})

Create a bucket

bucket, _ := b2.CreateBucket("test_bucket", backblaze.AllPrivate)

Uploading a file

reader, _ := os.Open(path)
name := filepath.Base(path)
metadata := make(map[string]string)

file, _ := bucket.UploadFile(name, metadata, reader)

All API methods except B2.AuthorizeAccount and Bucket.UploadHashedFile will retry once if authorization fails, which allows the operation to proceed if the current authorization token has expired.

To disable this behaviour, set B2.NoRetry to true

b2 command line client

A test applicaiton has been implemented using this package, and can be found in the /b2 directory. It should provide you with more examples of how to use the API in your own applications.

To install the b2 command, use:

go get -u gopkg.in/kothar/go-backblaze.v0/b2

$ b2 --help
Usage:
  b2 [OPTIONS] <command>

Application Options:
      --account= The account ID to use [$B2_ACCOUNT_ID]
      --appKey=  The application key to use [$B2_APP_KEY]
  -b, --bucket=  The bucket to access [$B2_BUCKET]
  -d, --debug    Debug API requests
  -v, --verbose  Display verbose output

Help Options:
  -h, --help     Show this help message

Available commands:
  createbucket  Create a new bucket
  delete        Delete a file
  deletebucket  Delete a bucket
  get           Download a file
  list          List files in a bucket
  listbuckets   List buckets in an account
  put           Store a file

FAQs

Package last updated on 18 Jul 2021

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