storage

package
v0.0.0-...-93f578c Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultKeyBuilder

func DefaultKeyBuilder(prefix string) func(fileName string, dir ...string) string

func KeepFileNameKeyBuilder

func KeepFileNameKeyBuilder() func(fileName string, dir ...string) string

Types

type FileUploadResult

type FileUploadResult struct {
	Key string `json:"key"`
}

type FileUploadToken

type FileUploadToken struct {
	Token string `json:"token"`
	Key   string `json:"key"`
	URL   string `json:"url"`
}

type FileUploader

type FileUploader interface {
	UploadFile(ctx context.Context, file io.Reader, size int64, key string) (*FileUploadResult, error)
	UploadLocalFile(ctx context.Context, file string, key string) (*FileUploadResult, error)
}

type Storage

type Storage interface {
	URLHandler
	FileUploader
	TokenGenerator
}

type TokenGenerator

type TokenGenerator interface {
	GenerateUploadToken(fileName string, dir string, nameBuilder func(filename string, dir ...string) string) FileUploadToken
}

type URLHandler

type URLHandler interface {
	GenerateURL(key string) string
	GenerateURLs(keys []string) []string
	GenerateImageURL(key string, width int) string
	ExtractKeyFromURL(uri string) string
	ExtractKeyFromURLWithMode(uri string, strict bool) (string, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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