storage

package
v1.46.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2023 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NamingStrategyTypeSerial  string = "serial"
	NamingStrategyTypePattern string = "pattern"
)
View Source
const (
	StatusDefault    int = 0
	StatusProcessing int = 1
	StatusFailed     int = 2
)
View Source
const ItemPerDir = 1000

Variables

View Source
var ErrImageNotFound = errors.New("image not found")

Functions

This section is empty.

Types

type Dir

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

func NewDir

func NewDir(bucket string, config config.ImageStorageNamingStrategyConfig) (*Dir, error)

func (*Dir) Bucket

func (d *Dir) Bucket() string

func (*Dir) NamingStrategy

func (d *Dir) NamingStrategy() NamingStrategy

type FlushOptions

type FlushOptions struct {
	Image  int
	Format string
}

type GenerateOptions

type GenerateOptions struct {
	Pattern       string
	Extension     string
	Index         int
	Count         int
	PreferredName string
}

type Image

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

func (Image) Dir

func (s Image) Dir() string

func (Image) FileSize

func (s Image) FileSize() int

func (Image) Filepath

func (s Image) Filepath() string

func (Image) Height

func (s Image) Height() int

func (Image) ID

func (s Image) ID() int

func (Image) Src

func (s Image) Src() string

func (Image) Width

func (s Image) Width() int

type NamingStrategy

type NamingStrategy interface {
	Generate(GenerateOptions) string
}

type NamingStrategyPattern

type NamingStrategyPattern struct{}

func (NamingStrategyPattern) Generate

func (s NamingStrategyPattern) Generate(options GenerateOptions) string

type NamingStrategySerial

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

func (NamingStrategySerial) Generate

func (s NamingStrategySerial) Generate(options GenerateOptions) string

type Storage

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

func NewStorage

func NewStorage(db *goqu.Database, config config.ImageStorageConfig) (*Storage, error)

func (*Storage) AddImageFromBlob

func (s *Storage) AddImageFromBlob(
	ctx context.Context,
	blob []byte,
	dirName string,
	options GenerateOptions,
) (int, error)

func (*Storage) AddImageFromFile

func (s *Storage) AddImageFromFile(
	ctx context.Context,
	file string,
	dirName string,
	options GenerateOptions,
) (int, error)

func (*Storage) ChangeImageName

func (s *Storage) ChangeImageName(ctx context.Context, imageID int, options GenerateOptions) error

func (*Storage) Flop

func (s *Storage) Flop(ctx context.Context, imageID int) error

func (*Storage) Flush

func (s *Storage) Flush(ctx context.Context, options FlushOptions) error

func (*Storage) FormattedImage

func (s *Storage) FormattedImage(ctx context.Context, id int, formatName string) (*Image, error)

func (*Storage) FormattedImages

func (s *Storage) FormattedImages(ctx context.Context, imageIds []int, formatName string) (map[int]Image, error)

func (*Storage) Image

func (s *Storage) Image(ctx context.Context, id int) (*Image, error)

func (*Storage) Normalize

func (s *Storage) Normalize(ctx context.Context, imageID int) error

func (*Storage) RemoveImage

func (s *Storage) RemoveImage(ctx context.Context, imageID int) error

func (*Storage) SetImageCrop

func (s *Storage) SetImageCrop(ctx context.Context, imageID int, crop sampler.Crop) error

Jump to

Keyboard shortcuts

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