Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

l0wl3vel/bunnystorage-go

 
 

Repository files navigation

bunnystorage-go

Go Documentation Go Report Card builds.sr.ht status

Package bunnystorage is a simple and easy-to-use package for interacting with the Bunny.net Edge Storage API. It provides a convenient way to manage files in your storage zones.

Installation

To install bunnystorage, run:

go get git.sr.ht/~jamesponddotco/bunnystorage-go

Usage

package main

import (
	"context"
	"log"
	"os"

	"git.sr.ht/~jamesponddotco/bunnystorage-go"
)

func main() {
	readOnlyKey, ok := os.LookupEnv("BUNNYNET_READ_API_KEY")
	if !ok {
		log.Fatal("missing env var: BUNNYNET_READ_API_KEY")
	}

	readWriteKey, ok := os.LookupEnv("BUNNYNET_WRITE_API_KEY")
	if !ok {
		log.Fatal("missing env var: BUNNYNET_WRITE_API_KEY")
	}

	// Create new Config to be initialize a Client.
	cfg := &bunnystorage.Config{
		Application: &bunnystorage.Application{
			Name:    "My Application",
			Version: "1.0.0",
			Contact: "contact@example.com",
		},
		StorageZone: "my-storage-zone",
		Key:         readWriteKey,
		ReadOnlyKey: readOnlyKey,
		Endpoint:    bunnystorage.EndpointFalkenstein,
	}

	// Create a new Client instance with the given Config.
	client, err := bunnystorage.NewClient(cfg)
	if err != nil {
		log.Fatal(err)
	}

	// List files in the storage zone.
	files, _, err := client.List(context.Background(), "/")
	if err != nil {
		log.Fatal(err)
	}

	for _, file := range files {
		log.Printf("File: %s, Size: %d\n", file.ObjectName, file.Length)
	}
}

For more examples and usage details, please check the Go reference documentation.

Contributing

Anyone can help make bunnystorage better. Check out the contribution guidelines for more information.

Resources

The following resources are available:


Released under the MIT License.

About

Unofficial Go client for Bunny.net's edge storage API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 96.3%
  • Makefile 3.7%