[**Documentation**](../../../../README)

***

[Documentation](../../../../README) / [@zerotal/admin](../../README) / [index](../README) / mediaPath

# Function: mediaPath()

> **mediaPath**(`name`, `folder?`): `string`

Defined in: [admin/src/media.ts:97](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/admin/src/media.ts#L97)

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`
