Documentation ¶
Index ¶
- Constants
- Variables
- func CleanName(name string) string
- func FileFromName(id etx.TxId, version int, name string) string
- func NameFromFile(fileName string) string
- func Status(filename string) int
- func Thumbnail(filename string) string
- type Bind
- type Claim
- type DB
- type OpCancel
- type OpDelete
- type Uploaded
- type Uploader
- func (up *Uploader) Begin() (string, error)
- func (up *Uploader) Commit(tx etx.TxId) error
- func (up *Uploader) Delete(tx etx.TxId, filename string) error
- func (up *Uploader) ForOperation(opType int) etx.Op
- func (up *Uploader) Initialise(log *log.Logger, db DB, tm *etx.TM)
- func (up *Uploader) MediaType(name string) int
- func (up *Uploader) Name() string
- func (up *Uploader) Operation(id etx.TxId, opType int, op etx.Op)
- func (up *Uploader) Save(fh *multipart.FileHeader, tx etx.TxId, version int) (err error, byClient bool)
- func (up *Uploader) StartBind(tx etx.TxId) *Bind
- func (up *Uploader) StartClaim(tx etx.TxId) *Claim
- func (up *Uploader) StartClaimV1(tx etx.TxId) *Claim
- func (up *Uploader) Stop()
- func (up *Uploader) V1()
- func (up *Uploader) ValidCode(tx etx.TxId) bool
Constants ¶
const ( MediaImage = 1 MediaVideo = 2 MediaAudio = 3 )
const ( OpOrphansV1Type = 0 OpCancelType = 1 OpDeleteType = 2 )
Operation types
Variables ¶
var WebFiles embed.FS
WebFiles are the package's web resources (templates and static files)
Functions ¶
func CleanName ¶
CleanName removes unwanted characters from a filename, to make it safe for display and storage. From https://stackoverflow.com/questions/54461423/efficient-way-to-remove-all-non-alphanumeric-characters-from-large-text. ## This is far more restrictive than we need.
func FileFromName ¶
FileFromName returns the stored file name for a newly uploaded file.
func NameFromFile ¶
NameFromFile returns the media file name from a file name.
Types ¶
type Bind ¶
type Bind struct {
// contains filtered or unexported fields
}
Context for a sequence of bind calls.
type Claim ¶
type Claim struct {
// contains filtered or unexported fields
}
Context for a sequence of claim calls and subsequent processing.
func (*Claim) End ¶
End requests notification when uploads are done. Any unclaimed temporary files are deleted.
type DB ¶
type DB interface {
Begin() func() // start transaction and return commit function
}
DB is an interface to the database manager that handles parent transactions.
type Uploader ¶
type Uploader struct { // parameters FilePath string MaxW int MaxH int MaxSize int // maximum size for AV to use original without processing ThumbW int ThumbH int MaxAge time.Duration // maximum time for a parent update DeleteAfter time.Duration // delay before deleting a file SnapshotAt time.Duration // snapshot time in video (-ve for none) AudioTypes []string VideoPackage string // software for video processing: ffmpeg, or a docker-hosted implementation of ffmpeg, for debugging VideoResolution int VideoTypes []string // contains filtered or unexported fields }
Uploader holds the parameters and state for uploading files. Typically only one is needed.
func (*Uploader) Begin ¶
Begin returns a transaction code for an update that may include a set of uploads. It expects that a database transaction (needed to write redo records) has been started.
func (*Uploader) Commit ¶
Commit makes temporary uploaded files permanent. It returns false if the transaction ID for a set of uploads has expired.
func (*Uploader) Delete ¶
Delete removes a media file after a delay to allow for cached web pages holding references to be aged.
func (*Uploader) Initialise ¶
Initialise starts the file uploader.
func (*Uploader) Save ¶
func (up *Uploader) Save(fh *multipart.FileHeader, tx etx.TxId, version int) (err error, byClient bool)
Save creates a temporary copy of an uploaded file, to be processed later.
func (*Uploader) StartBind ¶
StartBind initiates linking a parent object to a set of uploaded files, returning a context for calls to Bind and EndBind.
func (*Uploader) StartClaim ¶
StartClaim prepares for the client to identify the files it references.
func (*Uploader) StartClaimV1 ¶
StartClaimV1 prepares for the client to identify the files it references.