layout

package
v0.58.4 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 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         the item's one manifest; never served
                            /originals/sha256-{hex} uploads; never served
                            /temp/u-{uuid}          staged multipart uploads until placed; never served
                            /temp/e-{hex}           editor views; editor token only
                            /private/sha256-{hex}   every rendition; token-gated
                            /public/sha256-{hex}    copies of the exposed renditions; anyone

originals/, private/ and public/ names are the SHA-256 of the object, so objects are immutable: a change writes a new name. temp/ is discardable: nothing a viewer needs lives there, and the sweep wipes it by age.

Index

Constants

View Source
const (
	AreaManifest  = "manifest"
	AreaOriginals = "originals"
	AreaTemp      = "temp"
	AreaPrivate   = "private"
	AreaPublic    = "public"
)

Folder areas.

View Source
const (
	SHA256Prefix = "sha256-"
	UploadPrefix = "u-"
	InlinePrefix = "i-"
	EditorPrefix = "e-"
)
View Source
const ManifestName = "manifest.json"

ManifestName is the manifest's key within the folder.

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: temp/ for a "u-{uuid}" not yet placed, originals/ for a "sha256-{hex}".

func ValidEditorName added in v0.52.0

func ValidEditorName(name string) bool

ValidEditorName accepts "e-{64 lowercase hex}", an editor view.

func ValidHashName added in v0.48.0

func ValidHashName(name string) bool

ValidHashName accepts "sha256-{64 lowercase hex}".

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 ValidSourceName added in v0.48.0

func ValidSourceName(name string) bool

ValidSourceName accepts an uploaded file's name: a hash, or "u-{uuid}" until the worker places it.

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
	Name             string // file name within the area; "" for the manifest
}

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.

Jump to

Keyboard shortcuts

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