storage

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package storage provides blob storage for media files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Blob

type Blob interface {
	// ClipPath returns the local path for a clip file.
	ClipPath(id string) string
	// DeleteFile deletes the object identified by path.
	DeleteFile(path string) error
	// FileExists reports whether the object identified by path exists.
	FileExists(path string) bool
	// Get downloads the object to the local path for ffmpeg or HTTP serving.
	Get(ctx context.Context, path string) error
	// GifPath returns the local path for a GIF file.
	GifPath(id string) string
	// PreviewPath returns the local path for a preview file.
	PreviewPath(id string) string
	// Put uploads the local path after ffmpeg writes it.
	Put(ctx context.Context, path string) error
	// ScreenshotPath returns the local path for a screenshot file.
	ScreenshotPath(id string) string
	// ThumbnailPath returns the local path for a thumbnail file.
	ThumbnailPath(id string) string
	// WriteThumbnail stores thumbnail bytes under the given id.
	WriteThumbnail(id string, data []byte) error
}

Blob is the media object store used by the application.

func NewFromConfig

func NewFromConfig(
	cfg *config.Config,
) (Blob, error)

NewFromConfig constructs the storage backend selected by configuration.

type S3

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

S3 stores objects on an S3-compatible endpoint.

func (*S3) ClipPath

func (store *S3) ClipPath(id string) string

ClipPath returns the local scratch path for a clip file.

func (*S3) DeleteFile

func (store *S3) DeleteFile(path string) error

DeleteFile removes the object from S3 and the local scratch copy.

func (*S3) FileExists

func (store *S3) FileExists(path string) bool

FileExists reports whether the object exists, hydrating the local copy when needed.

func (*S3) Get

func (store *S3) Get(ctx context.Context, path string) error

Get downloads the object from S3 onto the local scratch path.

func (*S3) GifPath

func (store *S3) GifPath(id string) string

GifPath returns the local scratch path for a GIF file.

func (*S3) PreviewPath

func (store *S3) PreviewPath(id string) string

PreviewPath returns the local scratch path for a preview file.

func (*S3) Put

func (store *S3) Put(ctx context.Context, path string) error

Put uploads the local scratch file to S3.

func (*S3) ScreenshotPath

func (store *S3) ScreenshotPath(id string) string

ScreenshotPath returns the local scratch path for a screenshot file.

func (*S3) ThumbnailPath

func (store *S3) ThumbnailPath(id string) string

ThumbnailPath returns the local scratch path for a thumbnail file.

func (*S3) WriteThumbnail

func (store *S3) WriteThumbnail(id string, data []byte) error

WriteThumbnail stores thumbnail bytes locally and uploads them to S3.

type Storage

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

Storage provides filesystem storage.

func NewStorage

func NewStorage(basePath string) (*Storage, error)

NewStorage creates a new storage instance.

func (*Storage) BasePath

func (s *Storage) BasePath() string

BasePath returns the base storage path.

func (*Storage) ClipPath

func (s *Storage) ClipPath(id string) string

ClipPath returns the path for a clip file.

func (*Storage) ClipsDir

func (s *Storage) ClipsDir() string

ClipsDir returns the clips directory.

func (*Storage) DeleteFile

func (*Storage) DeleteFile(path string) error

DeleteFile deletes a file.

func (*Storage) FileExists

func (*Storage) FileExists(path string) bool

FileExists checks if a file exists.

func (*Storage) Get

func (*Storage) Get(_ context.Context, _ string) error

Get is a no-op on the filesystem backend because objects already live on disk.

func (*Storage) GifPath

func (s *Storage) GifPath(id string) string

GifPath returns the path for a GIF file.

func (*Storage) GifsDir

func (s *Storage) GifsDir() string

GifsDir returns the GIFs directory.

func (*Storage) PreviewPath

func (s *Storage) PreviewPath(id string) string

PreviewPath returns the path for a temporary preview file.

func (*Storage) PreviewsDir

func (s *Storage) PreviewsDir() string

PreviewsDir returns the previews directory.

func (*Storage) Put

func (*Storage) Put(_ context.Context, _ string) error

Put is a no-op on the filesystem backend because objects already live on disk.

func (*Storage) ScreenshotPath

func (s *Storage) ScreenshotPath(id string) string

ScreenshotPath returns the path for a screenshot file.

func (*Storage) ScreenshotsDir

func (s *Storage) ScreenshotsDir() string

ScreenshotsDir returns the screenshots directory.

func (*Storage) ThumbnailPath

func (s *Storage) ThumbnailPath(id string) string

ThumbnailPath returns the path for a thumbnail file.

func (*Storage) ThumbnailsDir

func (s *Storage) ThumbnailsDir() string

ThumbnailsDir returns the thumbnails directory.

func (*Storage) WriteThumbnail

func (s *Storage) WriteThumbnail(id string, data []byte) error

WriteThumbnail stores thumbnail bytes under the given id.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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