FiveMesh

Sacul

How to Move FiveM Images and NUI Assets to a CDN

Migrate FiveM inventory images, phone media and public NUI assets to a CDN without breaking URLs, uploads or resource delivery.

How to Move FiveM Images and NUI Assets to a CDN

Moving FiveM media to a CDN is not only an upload task. The real migration is changing every script, database record and interface that depends on the old URLs without interrupting the server.

Start by separating public assets from connection resources. Inventory icons, phone photos, videos, screenshots and web-loaded NUI assets can use stable CDN URLs. Vehicles, maps, clothing and other files downloaded as FiveM resources belong on the resource cache path instead.

A controlled FiveM asset migrationMove one asset group at a time so the old location remains available until every consumer has been verified.
01InventoryList paths, consumers and current public URLs.
02UploadCreate predictable CDN folders and preserve useful filenames.
03Cut overUpdate scripts, configuration and stored database URLs.
04Verify and retireTest every consumer before removing the old files.

Decide what belongs on the CDN

A CDN is the right destination when a file needs a stable public URL that can be loaded by a script, NUI page, website, Discord embed or browser.

Common CDN candidates include:

  • Inventory icons and item previews.
  • Phone photos, videos, avatars and social media.
  • Police evidence images and clips.
  • Vehicle thumbnails and dealership images.
  • Job logos, shop icons and character portraits.
  • Loading-screen media loaded from public URLs.
  • Static NUI images, fonts, JavaScript and styles that are intentionally hosted outside the resource package.

Do not move every file simply because it is large. A clothing pack or map downloaded while the player connects is still a FiveM resource. Use a FiveM cache proxy for that path.

Inventory the current asset paths

Before uploading, find every place that constructs or stores a URL.

Search:

  • Resource configuration files.
  • Lua, JavaScript and TypeScript source.
  • NUI HTML, CSS and bundled configuration.
  • Database columns containing full media URLs or relative paths.
  • Phone, inventory, dealership and evidence-script settings.
  • Web panels, documentation and Discord automation.

Record the current base URL, folder convention, filename rules, expected content types and which service writes each file.

This is also the time to identify dead files and duplicated paths. Migrating unused objects makes the cutover slower and preserves confusion you could remove first.

Design a stable folder structure

Use folders that reflect how the files are operated, not the name of whichever VPS currently hosts them.

For example:

inventory/items/water.png
inventory/items/repair-kit.png
phone/photos/player-123/2026/08/photo.jpg
police/evidence/case-456/clip.mp4
nui/dispatch/icons/priority.svg
vehicles/thumbnails/adder.webp

Stable conventions make URLs predictable and make future cleanup safer. Avoid putting secrets, license identifiers or internal hostnames in public paths.

When several scripts already agree on relative paths, preserve those paths under the new CDN base URL. That can turn a large migration into one base-URL change instead of thousands of individual replacements.

Move static assets first

Inventory images, job logos and NUI assets are usually the safest first batch because they change less often than player uploads.

  1. Upload the files to their planned CDN folders.
  2. Confirm each object has the correct Content-Type.
  3. Open representative URLs from a normal browser.
  4. Test the URLs inside the actual FiveM interface.
  5. Update one non-critical consumer first.
  6. Expand the cutover after the first group is stable.

Keep the old files available during this phase. Removing them before every script has been updated turns a reversible migration into an outage.

Update scripts without hardcoding every URL

Prefer one configurable CDN base URL:

local cdnBaseUrl = "https://cdn.example.com"
local itemIcon = ("%s/inventory/items/%s.png"):format(cdnBaseUrl, itemName)

The specific integration will differ by script, but the principle stays the same. Keep the base URL in server-side configuration or a shared resource instead of scattering it through many files.

For NUI bundles, confirm whether an asset is loaded by an absolute public URL or packaged with the resource. Do not point a bundled relative import at a CDN without checking how the build tool rewrites it.

Migrate database URLs carefully

Phone systems and evidence tools often store full URLs in the database.

If the path after the hostname stays identical, a controlled hostname replacement may be possible. If the folder structure changes, create an explicit mapping and update records in batches.

Before changing production data:

  1. Back up the relevant rows.
  2. Test the transformation on a copy.
  3. Count how many values will change.
  4. Update a small batch.
  5. Verify the affected media in the real script.
  6. Keep a rollback mapping until the migration is complete.

Do not rewrite every URL in the database based only on a broad text replacement. Other domains, malformed values and historical formats may exist in the same column.

Handle new player uploads separately

Migrating old media solves only half of the problem. The phone, evidence or upload script also needs to send new files to the CDN.

Keep permanent service credentials on the server side. A client-visible NUI or Lua resource should request a short-lived, scoped upload target rather than receive a reusable API key.

A safer upload flow is:

Client asks your server for upload permission
-> server validates the player and file
-> server requests a short-lived upload URL
-> client uploads to that target
-> final public URL is stored by the script

The FiveMesh CDN API documentation and scoped upload guide cover the current integration options.

Check CORS, MIME types and video playback

A URL opening in one browser tab does not prove every FiveM interface can use it.

Test images in NUI, videos with seeking, and uploads from the actual resource. Confirm the CDN returns the correct content type and supports the browser behavior the script expects. Video players may rely on partial requests, while NUI requests may depend on suitable CORS behavior.

Use representative files rather than one tiny PNG. A migration can look complete until the first larger video or less common MIME type reaches production.

Replace assets without creating stale URLs

When an asset changes, decide whether the public URL should remain stable.

For versioned application assets, a new filename such as dispatch-v2.js or a content hash makes the change explicit. For stable inventory paths, replace the object and use the CDN purge workflow when the old response must be invalidated.

Do not purge unrelated FiveM Cache entries when changing a public CDN image. CDN assets and connection resources are different products with different cache identities.

Add graceful fallbacks

Real servers eventually reference a missing icon or deleted media object.

FiveMesh CDN can apply pattern-based placeholders so paths such as inventory/items/* return a deliberate fallback image when the requested object is missing. That protects the interface while the underlying path is corrected.

Read CDN Placeholders for Missing FiveM Images for the complete fallback flow. A placeholder is a safer failure mode, not a reason to ignore broken paths permanently.

Verify before removing the old host

Build a short cutover checklist for each asset group.

  • New URLs return successful responses.
  • Content types match the files.
  • Inventory, phone, evidence and NUI consumers render correctly.
  • New uploads land in the expected CDN folder.
  • Database records store the final public URL.
  • Deletes and moderation actions still work.
  • Old URLs are no longer being generated.
  • Logs show no repeated missing objects or blocked requests.

Leave the old host available for a defined observation window. Remove it only when production traffic and script behavior show that the migration is complete.

Using FiveMesh CDN

FiveMesh CDN provides public URLs, dashboard uploads, object browsing, folders, API access, scoped upload flows, purge operations and placeholders for common FiveM media workflows.

For the broader storage and security model, read How to Host FiveM Images, Videos and Phone Media. If the files are downloaded when players connect, use the fileserver_add and adhesive_cdnKey setup guide instead.

A safe CDN migration is incremental: classify the files, preserve useful paths, update one consumer at a time, verify new uploads, and retire the old host only after the traffic has moved.