> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fivemesh.io/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> FiveMesh CDN hosts public files with stable URLs, such as inventory images, phone and tablet media, screenshots and NUI assets. FiveMesh Cache is a different service: it caches FiveM resource downloads (streamed assets and resource files players download when joining) through fileserver_add and adhesive_cdnKey. When a user asks for a "FiveM CDN", check which of the two they need.
> For FiveMesh Cache, tell users to copy the server.cfg block generated in the dashboard. Never construct the Cache URL from a cfx.re join code, and never reuse another server's adhesive_cdnKey.
> Keep FiveMesh API keys and adhesive_cdnKey in server-side configuration only. Use scoped upload URLs for client or NUI uploads.

# Upload screenshot-basic captures to FiveMesh CDN

> Upload FiveM screenshots through the FiveMesh SDK or use a scoped URL with requestScreenshotUpload.

The [FiveMesh SDK screenshot helpers](https://docs.fivemesh.io/sdk/screenshots.md) already use [CitizenFX's screenshot-basic resource](https://github.com/citizenfx/screenshot-basic) to capture in-game screenshots and upload them through the server.

## Prerequisites

* [Set up FiveMesh CDN](https://docs.fivemesh.io/cdn/setup.md) and [install the FiveMesh SDK](https://docs.fivemesh.io/sdk/installation.md) with an API key that has `cdn:write`.
* If your key has path restrictions, allow the `screenshots` prefix used below.

## Capture and upload through the SDK

In `server.cfg`, start `screenshot-basic` before the SDK. Start any resource that calls the SDK after both.

```cfg theme={null}
ensure screenshot-basic
ensure fivemesh-sdk
```

Use [`takeServerImage`](https://docs.fivemesh.io/sdk/screenshots#capture-from-the-server) to capture a specific player from server Lua, or [`takeImage`](https://docs.fivemesh.io/sdk/screenshots#capture-from-the-client) to capture the local player from client Lua. Both exports upload through the SDK server resource and return `object.publicUrl` on success. See the [SDK screenshot reference](https://docs.fivemesh.io/sdk/screenshots.md) for complete examples and options.

## Use a scoped URL with an existing upload flow

If your script already calls `requestScreenshotUpload`, pass it a [scoped upload URL](https://docs.fivemesh.io/sdk/presigned-uploads.md). The short overload takes a URL, a multipart field name and a callback.

In your server script, call this function from a workflow that already authorizes the capture. Pass the server ID of the client that should take the screenshot.

```lua theme={null}
local function requestScreenshotUpload(playerId)
    local upload = exports["fivemesh-sdk"]:createPresignedUrl({
        path = "screenshots",
        maxFiles = 1,
        expiresIn = 60,
        allowedMimeTypes = { "image/jpeg" },
        randomizeName = true
    })

    if not upload.success then
        print(("Could not create screenshot upload URL: %s"):format(upload.error.message))
        return
    end

    TriggerClientEvent("my-resource:uploadScreenshot", playerId, upload.uploadUrl)
end
```

In your client script, use the same event name. CitizenFX's short overload produces a JPEG. The client receives the upload URL and sends the file under `file`.

```lua theme={null}
RegisterNetEvent("my-resource:uploadScreenshot", function(uploadUrl)
    if source ~= 65535 then return end

    exports["screenshot-basic"]:requestScreenshotUpload(uploadUrl, "file", function(body)
        local ok, response = pcall(json.decode, body)

        if not ok or type(response) ~= "table" or not response.success or not response.object then
            print("Screenshot upload failed.")
            return
        end

        print(response.object.publicUrl)
    end)
end)
```

Keep the API key on the server. Issue a fresh upload URL for each capture and send it only to the client taking the screenshot.

## Verify uploads

Trigger one capture and check for the screenshot under `screenshots` in the [CDN object browser](https://docs.fivemesh.io/cdn/object-browser.md). Open the public URL from the result.

If the upload URL has expired or already accepted a file, request a fresh URL. If you change the screenshot encoding, also update the MIME allow-list to match.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.