storage

package
v0.0.0-...-41ce98d Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2024 License: BSD-2-Clause Imports: 12 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	S3Region   = "us-west-2"
	S3Endpoint string

	S3AccessKeyID     string
	S3AccessKeySecret string

	// for R2
	CFAccountID string
)

Functions

func EnqueueFile

func EnqueueFile(event FileEvent) error

func Init

func Init(cfg Config)

func IsCacheEnabled

func IsCacheEnabled() bool

func QueueAck

func QueueAck(msgid string) error

func UseSQS

func UseSQS(region, href string)

func UsingQueue

func UsingQueue() bool

Types

type Config

type Config struct {
	Type StorageType

	FilesBucket   string
	UploadsBucket string
	CacheBucket   string

	Region   string
	Endpoint string

	AccessKeyID     string
	AccessKeySecret string

	// for R2
	CFAccountID string

	// for SQS
	SQSURL    string
	SQSRegion string
}

type FileEvent

type FileEvent struct {
	UserID int
	FileID string
	Path   string
}

type Retryer

type Retryer struct {
	client.DefaultRetryer
}

func (Retryer) ShouldRetry

func (r Retryer) ShouldRetry(req *request.Request) bool

type S3Bucket

type S3Bucket struct {
	S3   *s3.S3
	Name string
	Type StorageType
}
var (
	FilesBucket   S3Bucket
	UploadsBucket S3Bucket
	CacheBucket   S3Bucket
)

func (S3Bucket) Copy

func (b S3Bucket) Copy(dst, src string) error

func (S3Bucket) CopyFromBucket

func (b S3Bucket) CopyFromBucket(dst string, srcBucket S3Bucket, src string, mime, contentDisp string) error

func (S3Bucket) Delete

func (b S3Bucket) Delete(key string) error

func (S3Bucket) Exists

func (b S3Bucket) Exists(key string) bool

func (S3Bucket) Get

func (b S3Bucket) Get(key string) (io.ReadCloser, error)

func (S3Bucket) Head

func (b S3Bucket) Head(key string) (S3Head, error)

func (S3Bucket) Keys

func (b S3Bucket) Keys() ([]string, error)

func (S3Bucket) List

func (b S3Bucket) List(prefix string) (map[string]S3Head, error)

func (S3Bucket) PresignGet

func (b S3Bucket) PresignGet(key string, ttl time.Duration) (string, error)

func (S3Bucket) PresignPut

func (b S3Bucket) PresignPut(key string, size int64, disp string, ttl time.Duration) (string, error)

func (S3Bucket) Put

func (b S3Bucket) Put(contentType, key string, r io.ReadSeeker) error

type S3Head

type S3Head struct {
	Type string
	Size int64
}

type StorageType

type StorageType string
const (
	StorageTypeS3 StorageType = "s3"
	StorageTypeB2 StorageType = "b2"
	StorageTypeR2 StorageType = "r2"
)

Jump to

Keyboard shortcuts

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