s3

package
v0.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package s3 is a small client for S3 and the services that speak its protocol, such as Cloudflare R2, Backblaze B2, Wasabi and MinIO. It does only what off-site backups need: put, get, delete and list objects.

Index

Constants

View Source
const DefaultRegion = "us-east-1"

DefaultRegion is used when none is given. Services with no regions of their own, R2 among them, accept it.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to one bucket.

func New

func New(cfg Config) (*Client, error)

New checks cfg and returns a client for its bucket. Nothing is sent yet.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, key string) error

Delete removes key. A key that is not there is no error.

func (*Client) Get

func (c *Client) Get(ctx context.Context, key string) (io.ReadCloser, int64, error)

Get opens key for reading. The caller closes the body.

func (*Client) List

func (c *Client) List(ctx context.Context, prefix string) ([]Object, error)

List returns every object whose key starts with prefix.

func (*Client) Put

func (c *Client) Put(ctx context.Context, key string, r io.ReaderAt, size int64) error

Put uploads size bytes of r as key. A large file goes up in parts, each sent again on its own if it fails.

type Config

type Config struct {
	// Endpoint is the service's address, such as
	// https://s3.eu-central-1.amazonaws.com.
	Endpoint  string `json:"endpoint"`
	Region    string `json:"region"`
	Bucket    string `json:"bucket"`
	AccessKey string `json:"access_key"`
	SecretKey string `json:"secret_key"`
}

Config says where a bucket is and how to sign in to it.

type Error

type Error struct {
	Status  int
	Code    string
	Message string
}

Error is a failure the service reported.

func (*Error) Error

func (e *Error) Error() string

type Object

type Object struct {
	Key      string
	Size     int64
	Modified time.Time
}

Object is one entry of a listing.

Directories

Path Synopsis
Package s3test has a fake S3 bucket for tests.
Package s3test has a fake S3 bucket for tests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL