layout

package
v0.46.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package layout defines media object keys, dependency-free so the access worker can classify paths without importing the media runtime:

{tenant}/{kind}/{content_id}/manifest.json | manifests/{version}.json
                            /originals/{sha256-hex | slot | slot.json | i-uuid}
                            /staging/{u-uuid}                               multipart uploads until placed; never served
                            /blobs/{sha256-hex | u-uuid}                    viewer token
                            /editor/{sha256-hex | name.webp}                editor token
                            /public/{name}.webp

Index

Constants

View Source
const (
	AreaManifest  = "manifest" // manifest.json and manifests/{version}.json
	AreaOriginals = "originals"
	AreaBlobs     = "blobs"
	AreaPublic    = "public"
	// AreaEditor holds what only editors may fetch: EditorOnly variant blobs
	// and video posters before they are published.
	AreaEditor = "editor"
	// AreaStaging holds multipart uploads (u-{uuid}) until the media worker
	// hashes them and places them in originals/ under their SHA-256.
	AreaStaging = "staging"
)

Folder areas.

View Source
const (
	SHA256Prefix = "sha256-"
	UploadPrefix = "u-"
	InlinePrefix = "i-"
	PublicExt    = ".webp"
)

Variables

This section is empty.

Functions

func ParseSHA256Name

func ParseSHA256Name(name string) ([]byte, bool)

ParseSHA256Name returns the digest of a "sha256-{hex}" name.

func SourceArea added in v0.40.0

func SourceArea(name string) string

SourceArea is where an uploaded file named name lives: staging/ for a "u-{uuid}" not yet placed, originals/ for a "sha256-{hex}".

func ValidBlobName

func ValidBlobName(name string) bool

ValidBlobName accepts "sha256-{64 lowercase hex}" and "u-{uuid}".

func ValidInlineName added in v0.17.0

func ValidInlineName(name string) bool

ValidInlineName accepts "i-{uuid}", an inline image's id.

func ValidSegment

func ValidSegment(s string) bool

ValidSegment keeps keys stable ASCII: [A-Za-z0-9._-]{1,128}, no leading dot.

func ValidStagedName added in v0.40.0

func ValidStagedName(name string) bool

ValidStagedName accepts "u-{uuid}", an upload whose hash is not yet known.

Types

type Key

type Key struct {
	Tenant, Kind, ID string
	Area             string // AreaManifest, AreaOriginals, AreaStaging, AreaBlobs, AreaEditor or AreaPublic
	Name             string // file name within the area; the version id for manifests/
}

Key is a parsed object key.

func Parse

func Parse(key string) (Key, bool)

Parse classifies an object key; ok is false for anything outside the layout, including keys nested deeper than it allows.

Jump to

Keyboard shortcuts

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