publish-vod/pkg/uploader/interface.go

41 lines
1.1 KiB
Go
Raw Permalink Normal View History

// Package uploader defines the interface to implement when building
// uploaders
package uploader
import (
"context"
"io"
"github.com/Luzifer/go_helpers/v2/fieldcollection"
"github.com/cheggaaa/pb/v3"
)
type (
// Uploader defines the interface to implement on new uploaders
Uploader interface {
// Prepare is used to check authorizations, re-authorize uploaders
// and do preflight-checks in before the real upload is started
Prepare(ctx context.Context, opts Opts) error
// UploadFile is executed after Prepare and ValidateConfig and
// can concentrate on uploading the file to the respective target
UploadFile(ctx context.Context, opts Opts) error
// ValidateConfig is called before Prepare and UploadFile and
// must make sure the settings given are complete and valid
ValidateConfig(config *fieldcollection.FieldCollection) error
}
// Opts contains the require arguments for an Uploader
// to do its job
Opts struct {
Name string
Config *fieldcollection.FieldCollection
Filename string
Content io.Reader
Size int64
ProgressBar *pb.ProgressBar
FinalMessage func(format string, opts ...any)
}
)