Skip to main content
Use server exports when your FiveM resource needs to manage FiveMesh CDN objects.
The Server API Key only permits CDN uploads and Logs reads/writes. Use a Developer API Key with cdn:read, cdn:delete or cdn:purge for listing, deletion or purge. Configure it as the default or pass a named keyProfile.
The default API key is read from FIVEMESH_API_KEY, so these exports should be called from server-side Lua or JavaScript. Lua callers can read the returned value directly. Failed exports return success = false with an error payload. JavaScript callers can use the returned Promise with await.

Upload a file

Use uploadFile when you already have bytes, a data URL or a Blob-compatible value.
Upload responses include the stored object and its publicUrl. canvas.toDataURL() values and raw binary strings produced by atob() can be passed directly. When the value is bare base64 without a data: prefix, declare the representation explicitly:

Upload an image data URL

Use uploadImage when a script gives you an image as a data URL.

Use an API key profile

Pass keyProfile when an export should use a named key such as FIVEMESH_API_KEY_MUGSHOTS instead of the default FIVEMESH_API_KEY.
The profile name is case-sensitive and is appended directly to FIVEMESH_API_KEY_.

Upload multiple files

Use bulkUpload when a resource needs to upload a small batch and handle per-file results.

List CDN objects

Use listObjects with a path and optional pagination limit.
If continuationToken is returned, pass it to the next call.

Delete objects

Use deleteObject for one path or bulkDelete for a batch.
Bulk delete returns one result per path, so your script can log partial failures.

Purge CDN files

Use purgeObjects when a resource needs FiveMesh to refresh public CDN files after an overwrite or external change. The paths are relative to your CDN workspace and must be allowed by the API key.
The API key needs cdn:purge for this export.

Inspect the key

Use whoami to check the configured key’s permissions and server binding without exposing its secret.
The SDK also checks identity at startup. Review its console output if Logs cannot resolve the server.

Export reference