# CDN

Keep the city's images, videos and sounds on a fast link for the inventory, the dealership, the loading screen and script screenshots.

Source: https://fivedash.fivex.gg/docs/en/cdn/overview

The **CDN** is the city's warehouse: one place for the images, videos and sounds the server uses, each file with a fast link. Inventory icons, dealership photos, loading screen backgrounds and the screenshots scripts send from the game live here, with no more Imgur going down or Discord links expiring. This page is for the owner and the staff who handle the server's files.

## Before you start

* **Plan:** the CDN module must be in the organization's plan. Storage depends on the plan and is per server (each server has its own CDN). See [Usage and limits](https://fivedash.fivex.gg/docs/en/cdn/usage-and-limits).
* **Create the CDN:** needs **Files** at the **Manage** level. Without it you see "Ask whoever manages the organization's files to open the CDN and create the address."

## Create the CDN

In **CDN → Files**, while the CDN doesn't exist, you see **…'s CDN hasn't been created yet**. Click **Create the CDN** and follow the three steps of **Keep the city's media in one place**.

### Pick the address

In **CDN address**, type the address (the default is `my-city`). FiveDash shows **Available** or **In use**. Click **Continue**.

### Set up the folders

Tick the folders the city uses (list below). Adjust **Optimize images** (the WebP quality) and, if you want, turn on **Start with sample files**. Click **Create … folders**, or **Start without folders**.

### Upload the first files

Pick the **Destination folder** and drag images, videos and audio into the upload area (or **choose from your computer**). Every file gets a link right away. Click **Open the CDN**.

### Suggested folders

| Folder                | Name in the link | What it's for                                   | Ticked by default |
| --------------------- | ---------------- | ----------------------------------------------- | ----------------- |
| **Inventory**         | `itens`          | Item icons, for ox_inventory and the like       | Yes               |
| **Vehicles**          | `veiculos`       | Dealership and garage photos                    | Yes               |
| **Loading screen**    | `loading-screen` | Backgrounds, logo and trailer                   | Yes               |
| **Screenshots**       | `screenshots`    | Screenshots scripts send from the game          | Yes               |
| **Logos and banners** | `marca`          | Logo, Discord and store banners                 | No                |
| **Clothing**          | `roupas`         | Clothing and accessory previews                 | No                |
| **Clips**             | `clipes`         | Event and promo videos                          | No                |
| **Sounds**            | `sons`           | Effects and music for xsound and interact-sound | No                |

> **Sample files** are real files to try the links. The uploads count toward the plan's allowance.

## The files' links

Every file has a public link in this format:

```http
https://cdn.fivex.sh/<address>/<folder>/<file>
```

For example: `https://cdn.fivex.sh/example-city/itens/agua.png`. Subfolders go in the path. On the Ultra plan, a domain of the city's can serve the same files (see [Custom domain](https://fivedash.fivex.gg/docs/en/cdn/custom-domain)).

| Address rule | Value                                                                                           |
| ------------ | ----------------------------------------------------------------------------------------------- |
| Length       | 3 to 32 characters                                                                              |
| Characters   | Lowercase letters, numbers and hyphens, no hyphen at either end                                 |
| Reserved     | `admin`, `api`, `cdn`, `assets`, `fivex`, `fivedash`, `static`, `health`, `internal`, `uploads` |
| Unique       | Can't belong to another city ("That address belongs to another city. Try another one.")         |

> Changing the address, renaming or moving a file changes its link. Scripts using the old link need the new one.

## Accepted formats

| Type   | Formats                   |
| ------ | ------------------------- |
| Images | PNG, JPEG, WebP, GIF, SVG |
| Videos | MP4, WebM, MOV            |
| Audio  | MP3, OGG, WAV, M4A        |

Any other file is rejected on upload. PNG, JPEG and WebP can be optimized into WebP; GIF, SVG, audio and video are served as uploaded.

## What's in the module

| Page         | Path in the panel  | What it does                                                                                        |
| ------------ | ------------------ | --------------------------------------------------------------------------------------------------- |
| **Files**    | **CDN → Files**    | Folders, uploads, search, preview, links, favorites and trash.                                      |
| **Usage**    | **CDN → Usage**    | Storage, traffic, hits, the month's allowances and most accessed files.                             |
| **Settings** | **CDN → Settings** | Address, custom domain, images, retention, uploads, protection, cache, upload keys and danger zone. |

## Settings

**CDN → Settings** holds how the CDN serves, stores and protects the files. Address, images, retention, uploads, protection and cache are saved together from the **Save** bar. Upload keys and **Delete the CDN** apply right away. With **Settings** at **View** only, the page shows "Your access lets you view, not change."

| Section           | Field                            | What it does                                                                                                                                                         | Default                    |
| ----------------- | -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- |
| **Address**       | **Public address**               | The start of every link: `cdn.fivex.sh/<address>`. Once a new address is saved, the old links stop working.                                                          | The one chosen at creation |
| **Custom domain** | **Subdomain**                    | A subdomain of the city's to serve the files (Ultra). See [Custom domain](https://fivedash.fivex.gg/docs/en/cdn/custom-domain).                                      | None                       |
| **Images**        | **Optimize images**              | The WebP quality, from 70% to 100%. At 100% (**Original**) it keeps the uploaded format.                                                                             | 85%                        |
| **Images**        | **Max width**                    | Larger images are scaled down on upload: **No limit**, 1920 px, 2560 px or 3840 px (4K).                                                                             | 2560 px                    |
| **Images**        | **Remove metadata**              | Strips location and camera data from photos before publishing.                                                                                                       | On                         |
| **Retention**     | Images, Videos, Audio            | Automatically deletes what gets old: **Keep forever**, 7, 14, 30, 60, 90, 180 days or 1 year. Everything goes to the trash first and is gone for good after 30 days. | **Keep forever**           |
| **Retention**     | **Favorites**                    | Starred files stay, however old.                                                                                                                                     | On                         |
| **Retention**     | **Protected folders**            | Folders (with everything inside) that retention never deletes.                                                                                                       | None                       |
| **Uploads**       | **Max size per file**            | The largest audio or video the team can upload from the panel: 25, 50, 100 or 250 MiB. Images go up to 20 MiB; the scripts API, up to 20 MiB.                        | 100 MiB                    |
| **Uploads**       | **Accepted formats**             | The list of accepted formats (read-only).                                                                                                                            | —                          |
| **Protection**    | **Only the city uses the files** | Stops other sites from displaying your files (and using up your traffic). The game, the NUI and the loading screen can always use them.                              | Off                        |
| **Protection**    | **Allowed sites**                | Domains that can also display the files, like `store.yourcity.com` or `*.yourcity.com`. Click **Allow** to add one. Up to 50.                                        | None                       |
| **Cache**         | **Cache time**                   | How long the CDN keeps copies: 1 day, 7 days, 30 days or 1 year. **Purge cache** makes everyone see the new version of a file replaced under the same name.          | 30 days                    |
| **Upload keys**   | **New key**                      | Keys for scripts that upload files on their own. See [Upload keys](https://fivedash.fivex.gg/docs/en/cdn/upload-keys).                                               | None                       |
| **Danger zone**   | **Delete the CDN**               | Takes down every file, folder, key and the address, and goes back to the initial setup.                                                                              | —                          |

> **Images** options apply to new uploads. When an image is processed, the final version replaces the original. Under **Retention**, the footer shows how many files go to the trash on the next cleanup (**See files**); cleanup runs automatically throughout the day.

## Access levels

Access is given in **Settings → Members**, **CDN** module.

| Area         | Level         | What it allows                                                  |
| ------------ | ------------- | --------------------------------------------------------------- |
| **Files**    | **View**      | See files and copy links                                        |
| **Files**    | **Manage**    | Upload, rename, move and send to the trash (and create the CDN) |
| **Files**    | **Configure** | Also delete forever and empty the trash                         |
| **Usage**    | **View**      | Storage, traffic and most accessed files                        |
| **Settings** | **View**      | Address, optimization and upload keys                           |
| **Settings** | **Configure** | Change optimization and protection, and create keys             |

## FAQ

**Are the files private?**
No. CDN links are public: anyone with the link opens the file. The **Only the city uses the files** option (in **CDN → Settings → Protection**) stops other sites from displaying your files, but the link stays public.

**Can scripts that take screenshots use the CDN?**
Yes. Create an upload key and use it in screenshot-basic or over HTTP. See [Upload keys](https://fivedash.fivex.gg/docs/en/cdn/upload-keys) and [Integrations](https://fivedash.fivex.gg/docs/en/cdn/integrations).

**How do I delete the whole CDN?**
In **CDN → Settings → Danger zone**, click **Delete the CDN** and confirm with **Delete everything**. Every file, folder, key and the address go offline right away. This can't be undone. It needs **Configure** on both **Files** and **Settings**.

## Next steps

[Upload files](https://fivedash.fivex.gg/docs/en/cdn/upload-files)Upload, rename, move and delete files.
[Upload keys](https://fivedash.fivex.gg/docs/en/cdn/upload-keys)Let scripts upload files on their own.
[Usage and limits](https://fivedash.fivex.gg/docs/en/cdn/usage-and-limits)Storage, traffic and plan allowances.
[Integrations](https://fivedash.fivex.gg/docs/en/cdn/integrations)screenshot-basic, ox_inventory and HTTP.
