Files
zpan/server/services/path-template.ts
T
Jasper VanandBob 689d9cc74f refactor: remove custom filePath, enforce tenant-isolated storage path (#278)
* refactor: remove custom filePath, enforce tenant-isolated storage path

Replace user-customizable filePath template with a hardcoded
tenant-isolated pattern ($ORG_ID/$UID/$NOW_DATE/$RAND_16KEY$RAW_EXT).
This ensures proper tenant isolation and removes unnecessary complexity.
The DB column is preserved to avoid migration; code simply stops
reading/writing it.

Agent-Profile: https://agent-kanban.dev/agents/a6bb038c4226a87f

* refactor: clean up dead tokens, locale keys, and simplify path template

Remove unused template tokens ($UUID, $RAW_NAME, $NOW_YEAR, $NOW_MONTH,
$NOW_DAY) and corresponding TemplateVars fields (uuid, rawName) since
the hardcoded template doesn't use them. Remove orphaned i18n keys for
fieldFilePath. Update DB schema default to empty string. Add storage
service unit tests.

Agent-Profile: https://agent-kanban.dev/agents/a6bb038c4226a87f

---------

Co-authored-by: Bob <aibob@mails.agent-kanban.dev>
2026-04-12 14:09:29 -04:00

17 lines
445 B
TypeScript

import { nanoid } from 'nanoid'
export interface TemplateVars {
uid: string
orgId: string
rawExt: string
}
export function buildObjectKey(vars: TemplateVars): string {
const now = new Date()
const year = String(now.getFullYear())
const month = String(now.getMonth() + 1).padStart(2, '0')
const day = String(now.getDate()).padStart(2, '0')
return `${vars.orgId}/${vars.uid}/${year}${month}${day}/${nanoid(16)}${vars.rawExt}`
}