uploads

package
v0.97.12 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package uploads is the canonical filesystem layout for files services produce on the local box: screenshots, generated images, PDFs, audit reports, anything else that needs to live somewhere predictable.

Convention:

$UPLOADS_ROOT/<service>/<bucket>/<filename>

where:

  • $UPLOADS_ROOT defaults to $HOME/uploads (override via env)
  • <service> is the producing service name (e.g. "go-wowa", "go-imagine", "vaelor")
  • <bucket> is the producer's internal grouping ("screenshots", "carousels", "cards", "imagined", "pdf", "audio") — chosen by the producer, kept short
  • <filename> is the actual file

Why a single pkg: every service was rolling its own /tmp/<svc>-* path pattern. Hard to find files, no shared retention policy, no operator overview. With this convention, `cd ~/uploads && ls` shows every service's recent output at a glance.

Usage:

dir, err := uploads.Bucket("go-wowa", "screenshots")  // creates dir if needed
path := filepath.Join(dir, "abc.png")

Or one-shot:

path, err := uploads.Path("vaelor", "imagined", "sf-rooftop.png")

Index

Constants

View Source
const DefaultRootRel = "uploads"

DefaultRootRel is the path appended to $HOME when EnvRoot is unset.

View Source
const EnvRoot = "UPLOADS_ROOT"

EnvRoot is the env var name that overrides the default uploads root.

Variables

This section is empty.

Functions

func Bucket

func Bucket(service, bucket string) (string, error)

Bucket returns $UPLOADS_ROOT/<service>/<bucket> and creates it if missing. The standard call-site pattern.

func Path

func Path(service, bucket, filename string) (string, error)

Path is a shortcut for filepath.Join(Bucket(service, bucket), filename). Returns the absolute path; the parent directory is created if missing. Filename is taken as-is, no sanitization — callers responsible for safety.

func Root

func Root() string

Root returns the canonical uploads root. Reads $UPLOADS_ROOT, then falls back to $HOME/uploads, then to /tmp/uploads if $HOME is unavailable. Does NOT create the directory — callers wanting on-disk presence should call Service or Bucket which do MkdirAll.

func Service

func Service(name string) (string, error)

Service returns $UPLOADS_ROOT/<service> and creates it if missing. Use when the service wants to manage its own internal layout below the canonical service-namespace.

Types

This section is empty.

Jump to

Keyboard shortcuts

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