media

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const ReferenceScheme = "media:"

Variables

View Source
var SupportedCollections = []string{"images", "videos", "audio", "documents", "uploads", "assets"}

Functions

func BuildStoredFilename

func BuildStoredFilename(safeName string, now time.Time) (string, error)

func ContentHash

func ContentHash(body []byte) string

func DefaultCollection

func DefaultCollection(filename, contentType string) string

func MustReference

func MustReference(collection, relPath string) string

func NewReference

func NewReference(collection, relPath string) (string, error)

func RewriteHTML

func RewriteHTML(html string) string

func SanitizeFilename

func SanitizeFilename(name string) string

func ShouldForceDownload

func ShouldForceDownload(name string) bool

Types

type Kind

type Kind string
const (
	KindImage Kind = "image"
	KindVideo Kind = "video"
	KindAudio Kind = "audio"
	KindFile  Kind = "file"
)

func DetectKind

func DetectKind(name string) Kind

type Reference

type Reference struct {
	Collection string
	Path       string
	PublicURL  string
	Kind       Kind
}

func ResolveReference

func ResolveReference(ref string) (Reference, error)

type UploadInfo

type UploadInfo struct {
	Collection       string
	OriginalFilename string
	SafeFilename     string
	StoredFilename   string
	MIMEType         string
	Extension        string
	Kind             Kind
	ContentHash      string
	Size             int64
	Width            int
	Height           int
}

func PrepareUpload

func PrepareUpload(requestedCollection, filename string, body []byte, now time.Time) (UploadInfo, error)

Jump to

Keyboard shortcuts

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