| 1 | /** Bucket prefix every release asset lives under. */ |
| 2 | export const RELEASE_ASSET_PREFIX = |
| 3 | |
| 4 | /** A single PutObject tops out at 5 GiB, and assets are uploaded in one. */ |
| 5 | export const RELEASE_ASSET_CEILING = |
| 6 | |
| 7 | export const DEFAULT_RELEASE_ASSET_MAX_BYTES = |
| 8 | |
| 9 | /** Where an asset's bytes live. A release's or a repository's assets can be removed by prefix. */ |
| 10 | export function releaseAssetKey( |
| 11 | repositoryId: string, |
| 12 | releaseId?: string |
| 13 | assetId?: string |
| 14 | ) { |
| 15 | return [RELEASE_ASSET_PREFIX, |
| 16 | .filter(Boolean) |
| 17 | .join('/') |
| 18 | .concat(assetId ? |
| 19 | } |
| 20 | |
| 21 | /** A file name, never a path: it becomes the last segment of a download URL and the name a browser saves. */ |
| 22 | export function isValidAssetName(name |
| 23 | return ( |
| 24 | name.length > 0 |
| 25 | name.length <= 255 |
| 26 | name !== '.' |
| 27 | name !== '..' |
| 28 | // no separators, no control characters |
| 29 | !/[/\\\u0000- |
| 30 | ); |
| 31 | } |