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.
To install bunnystorage
, run:
go get git.sr.ht/~jamesponddotco/bunnystorage-go
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.
Anyone can help make bunnystorage
better. Check out the contribution
guidelines
for more information.
The following resources are available:
- Package documentation.
- Support and general discussions.
- Patches and development related questions.
- Instructions on how to prepare patches.
- Feature requests and bug reports.
Released under the MIT License.