bucket

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package bucket provides support for listing S3 bucket contents and creating presigned URLs for fetching media. The AWS SDK is used to provide S3 functionality, however, any S3 compatible backend service is supported.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

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

func Open

func Open(config Config) (*Bucket, error)

Connect to the configured S3 bucket. Tested: Wasabi, Backblaze, Minio

func OpenAll

func OpenAll(buckets []Config) ([]*Bucket, error)

func OpenMedia

func OpenMedia(buckets []Config, mediaType string) ([]Bucket, error)

func (*Bucket) List

func (b *Bucket) List(lastSync time.Time) (objectCh chan *Object, err error)

func (*Bucket) Presign

func (b *Bucket) Presign(key string) *url.URL

Generate a presigned url which expires based on config settings.

func (*Bucket) Rewrite

func (b *Bucket) Rewrite(path string) string

type Config

type Config struct {
	Endpoint        string
	Region          string
	AccessKeyID     string
	SecretAccessKey string
	BucketName      string
	ObjectPrefix    string
	UseSSL          bool
	URLExpiration   time.Duration
	Media           string
	RewriteRules    []RewriteRule
}

type Object

type Object struct {
	Key          string
	Path         string // Key modified by rewrite rules
	ETag         string
	Size         int64
	LastModified time.Time
}

type RewriteRule

type RewriteRule struct {
	Pattern string
	Replace string
}

Jump to

Keyboard shortcuts

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