Skip to main content
zerotal

Documentation


Documentation / @zerotal/admin / index / mediaPath

Function: mediaPath()

mediaPath(name, folder?): string

Defined in: admin/src/media.ts:97

A storage path for an upload that will not collide with another.

The random prefix is the point: two people uploading logo.png on the same day must not overwrite each other, and a guessable path is a small information leak on a private disk. The original name is kept on the end so the file is still recognisable in a bucket listing.

The sanitising here is about producing a tidy, predictable key — it is not the defence against escaping the disk. The driver owns that, and rejects a traversing path with PathTraversalError whatever this produces.

Parameters

name

string

folder?

string = "media"

Returns

string