uploader

package
v0.0.0-...-8c72eba Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUploaderNotFound = errors.New("uploader not found with the given id")
	ErrUploaderDelete   = errors.New("uploader is being deleted")
	ErrUploaderInUse    = errors.New("uploader is in use and can't be deleted")
	ErrDigestAlgorithm  = errors.New("uploader doesn't support the digest algorithm")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	UserID      string   `json:"user"`
	Algs        []string `json:"digest_algorithms"`
	Description string   `json:"description"`
}

func (Config) UsesAlg

func (c Config) UsesAlg(alg string) bool

type Manager

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

func NewManager

func NewManager(fsys ocfl.WriteFS, dir string, persist Persistence) *Manager

func (*Manager) GetUploader

func (mgr *Manager) GetUploader(ctx context.Context, uploaderID string) (*Uploader, error)

func (*Manager) Len

func (mgr *Manager) Len(ctx context.Context) (int, error)

Len returns the number of uploads for a given upload root

func (*Manager) NewUploader

func (mgr *Manager) NewUploader(ctx context.Context, config *Config) (string, error)

func (*Manager) Root

func (mgr *Manager) Root() (ocfl.WriteFS, string)

func (*Manager) UploaderIDs

func (mgr *Manager) UploaderIDs(ctx context.Context) ([]string, error)

type Persistence

type Persistence interface {
	CreateUploader(ctx context.Context, vals *PersistentUploader) error
	CreateUpload(ctx context.Context, upID string, vals *Upload) error

	// list of all uploaderIDs
	GetUploaderIDs(ctx context.Context) ([]string, error)

	// GetUploader with all it's uploads
	GetUploader(ctx context.Context, id string) (*PersistentUploader, error)

	// Delete the uploader and all its uploads
	DeleteUploader(ctx context.Context, id string) error

	// number of uploaders
	CountUploaders(ctx context.Context) (int, error)
}

type PersistentUploader

type PersistentUploader struct {
	ID        string
	Config    Config
	CreatedAt time.Time
	Uploads   []Upload
}

type Upload

type Upload struct {
	// file name relative to uploader's root
	Name string `json:"name,omitempty"`
	// file size
	Size int64 `json:"size"`
	// digests for each algorithm used by the uploader
	Digests ocfl.DigestSet `json:"digests"`
}

Upload is an item in the Uploader manifest.

type Uploader

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

func (*Uploader) Close

func (up *Uploader) Close(ctx context.Context) error

func (*Uploader) Config

func (up *Uploader) Config() *Config

func (*Uploader) ContentSource

func (up *Uploader) ContentSource(alg string) ocfl.ContentSource

func (*Uploader) Created

func (up *Uploader) Created() time.Time

func (*Uploader) Delete

func (up *Uploader) Delete(ctx context.Context) error

func (*Uploader) FixitySource

func (up *Uploader) FixitySource(alg string) ocfl.FixitySource

func (*Uploader) Root

func (up *Uploader) Root() (ocfl.WriteFS, string)

func (*Uploader) Uploads

func (up *Uploader) Uploads() []Upload

func (*Uploader) Write

func (up *Uploader) Write(ctx context.Context, r io.Reader) (*Upload, error)

The Upload returned by write must not be modified!

Jump to

Keyboard shortcuts

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