Skip to content
/ b2 Public

A golang api client for Backblaze's B2 Cloud Storage

License

Notifications You must be signed in to change notification settings

ifo/b2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

b2

b2 is a [Backblaze B2 Cloud Storage] (https://www.backblaze.com/b2/cloud-storage.html) API client written in Go.

Usage

To use b2, import it and create an API client using your account ID and application key.

import (
	"github.com/ifo/b2"
)

b2api, err := b2.CreateB2(accountID, appKey)

Here are some examples:

Create a bucket:

bucket, err := b2api.CreateBucket("kitten-pictures", AllPublic)

Upload a file:

fileReader, err := os.Open("./path/to/kitten.jpg")
// handle err

fileMeta, err := bucket.UploadFile("kitten.jpg", fileReader, nil)

Download a file:

kittenFile, err := bucket.DownloadFileByName("kitten.jpg")
// handle err

err = ioutil.WriteFile(kittenFile.Meta.Name, kittenFile.Data, 0644)

Check for an API error:

kittenFile, err := bucket.DownloadFileByName("cat.jpg")
if err != nil {
	if err, ok := err.(APIError); ok {
		// this is an APIError
		fmt.Println(err.Message)
	}
}

TODO

  • Implement large file API
  • Integration tests
  • Example program

License

b2 is ISC licensed. Check out the LICENSE file.

About

A golang api client for Backblaze's B2 Cloud Storage

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages