storagex

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidKey

func ValidKey(key string) bool

Types

type LocalBackend

type LocalBackend struct {
	Root string
	// contains filtered or unexported fields
}

func NewLocal

func NewLocal(root string) (*LocalBackend, error)

func (*LocalBackend) Delete

func (l *LocalBackend) Delete(_ context.Context, key string) error

func (*LocalBackend) DeleteMulti

func (l *LocalBackend) DeleteMulti(ctx context.Context, keys ...string) error

func (*LocalBackend) LoadMeta

func (l *LocalBackend) LoadMeta(key string) (meta, error)

func (*LocalBackend) Open

func (*LocalBackend) Presign

func (l *LocalBackend) Presign(_ context.Context, key string, _ time.Duration) (string, error)

func (*LocalBackend) Put

func (l *LocalBackend) Put(_ context.Context, key, contentType string, r io.Reader) (Object, error)

func (*LocalBackend) URL

func (l *LocalBackend) URL(key string) string

type Object

type Object struct {
	Key         string `json:"key"`
	ContentType string `json:"content_type"`
	Size        int64  `json:"size"`
	SHA256      string `json:"sha256"`
}

type S3Backend

type S3Backend struct {
	Client     *s3.Client
	Uploader   *manager.Uploader
	Presigner  *s3.PresignClient
	Bucket     string
	Prefix     string
	PublicBase string
}

func NewS3

func NewS3(ctx context.Context, o S3Options) (*S3Backend, error)

func (*S3Backend) Delete

func (s *S3Backend) Delete(ctx context.Context, key string) error

func (*S3Backend) DeleteMulti

func (s *S3Backend) DeleteMulti(ctx context.Context, keys ...string) error

func (*S3Backend) Open

func (s *S3Backend) Open(ctx context.Context, key string) (io.ReadCloser, Object, error)

func (*S3Backend) Presign

func (s *S3Backend) Presign(ctx context.Context, key string, ttl time.Duration) (string, error)

func (*S3Backend) Put

func (s *S3Backend) Put(ctx context.Context, key, contentType string, r io.Reader) (Object, error)

func (*S3Backend) URL

func (s *S3Backend) URL(key string) string

type S3Options

type S3Options struct {
	Endpoint   string
	Region     string
	AccessKey  string
	SecretKey  string
	Bucket     string
	Prefix     string
	PublicBase string
	PathStyle  bool
}

type Store

type Store interface {
	Put(ctx context.Context, key, contentType string, r io.Reader) (Object, error)

	Open(ctx context.Context, key string) (io.ReadCloser, Object, error)

	Delete(ctx context.Context, key string) error

	DeleteMulti(ctx context.Context, keys ...string) error

	URL(key string) string

	Presign(ctx context.Context, key string, ttl time.Duration) (string, error)
}

Jump to

Keyboard shortcuts

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