> ## 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 ScreenCapture screenshots and clips to FiveMesh CDN

> Send ScreenCapture screenshots and WebM clips from your FiveM server to FiveMesh CDN.

Use ScreenCapture's server exports to capture screenshots and WebM clips. The FiveMesh SDK issues a scoped upload URL for each capture and ScreenCapture sends the file to that URL from 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 a key that has `cdn:write`. This guide uses the SDK's upload URL export.
* [Install ScreenCapture](https://screencapture.projecterror.dev/installation/) as `screencapture`. The examples use the exports available in [v0.17.2](https://github.com/itschip/screencapture/releases/tag/v0.17.2).
* Start both resources before the resource that runs these examples. If your key has path restrictions, allow `captures`.

## Create an upload URL

Place this helper in your server Lua file above the capture functions. It gives each capture its own upload URL, folder and MIME restriction. The API key stays in the SDK's server configuration.

```lua theme={null}
local function createCaptureUploadUrl(path, mimeType)
    local upload = exports["fivemesh-sdk"]:createPresignedUrl({
        path = path,
        maxFiles = 1,
        expiresIn = 300,
        allowedMimeTypes = { mimeType },
        randomizeName = true
    })

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

    return upload.uploadUrl
end
```

## Upload a screenshot

Call this function from your server script with the connected player's server ID. Pass `"blob"` to [`remoteUpload`](https://screencapture.projecterror.dev/screenshots/#remoteuploadsource-url-options-callback-datatype) so it sends multipart file data. The callback receives the decoded FiveMesh response.

```lua theme={null}
local function uploadScreenshot(playerId)
    local uploadUrl = createCaptureUploadUrl("captures/screenshots", "image/webp")
    if not uploadUrl then return end

    exports.screencapture:remoteUpload(playerId, uploadUrl, {
        encoding = "webp",
        formField = "file"
    }, function(response)
        if response and response.success and response.object then
            print(response.object.publicUrl)
        else
            print("ScreenCapture did not return an uploaded screenshot.")
        end
    end, "blob")
end
```

## Upload a video clip

Call this function with the connected player's server ID. [`startVideoCaptureUpload`](https://screencapture.projecterror.dev/video/#startvideocaptureuploadsource-url-options-callback) records a 10-second WebM clip and uploads it after the recording ends. The FiveMesh response is in `result.response`.

```lua theme={null}
local function uploadClip(playerId)
    local uploadUrl = createCaptureUploadUrl("captures/clips", "video/webm")
    if not uploadUrl then return end

    return exports.screencapture:startVideoCaptureUpload(playerId, uploadUrl, {
        duration = 10,
        formField = "file"
    }, function(result)
        if result.status ~= "success" then
            print(("ScreenCapture clip failed: %s"):format(result.error or "unknown error"))
            return
        end

        local response = result.response
        if response and response.success and response.object then
            print(response.object.publicUrl)
        else
            print("ScreenCapture did not return an uploaded clip.")
        end
    end)
end
```

## Verify uploads

Trigger both functions through your capture workflow. Open the public URLs and check for the files under `captures/screenshots` and `captures/clips` in the [CDN object browser](https://docs.fivemesh.io/cdn/object-browser.md).

If a capture fails, check the server console for ScreenCapture errors. For longer clips, leave enough time for recording and transfer before the upload URL expires. If the file exceeds your upload limit, shorten the clip or reduce the capture dimensions.


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