> ## 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 qb-phone camera photos to FiveMesh CDN

> Connect the qb-phone camera and gallery to FiveMesh CDN using the FiveMesh SDK screenshot export.

Use the [FiveMesh SDK screenshot export](https://docs.fivemesh.io/sdk/screenshots.md) to store qb-phone camera photos on FiveMesh CDN. The gallery receives the public URL through its existing server callback.

This example follows the upstream [qb-phone revision `333e813`](https://github.com/qbcore-fivem/qb-phone/commit/333e8132359b1c50c31c2bc6db8e8a64db6c93f6). If you run a fork, check that it uses the same camera callback and reads a JSON `url` field before applying the example.

## 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`.
* Start `screenshot-basic` before `fivemesh-sdk`. Start `qb-phone` after both resources and `qb-core`.
* If your API key has path restrictions, allow the `qb-phone` prefix.

## Connect the camera

1. In `qb-phone/config.lua`, set `Config.Fivemerr = true`. This upstream setting makes the camera use the server-side callback.
2. In `qb-phone/server.lua`, find the existing `qb-phone:server:UploadToFivemerr` callback. Replace the entire callback registration with the example below. Keep its name so the camera can still call it.
3. Save your changes and run `restart qb-phone` in the FiveM server console.

```lua theme={null}
local photoSequence = 0

QBCore.Functions.CreateCallback('qb-phone:server:UploadToFivemerr', function(source, cb)
    photoSequence = photoSequence + 1
    local filename = ("%d-%d-%d-%d.png"):format(os.time(), source, GetGameTimer(), photoSequence)
    local result = exports["fivemesh-sdk"]:takeServerImage(source, nil, {
        encoding = "png",
        filename = filename,
        path = "qb-phone"
    })

    if not result.success then
        print(("FiveMesh gallery upload failed: %s"):format(result.error.message))
        return cb(nil)
    end

    cb(json.encode({ url = result.object.publicUrl }))
end)
```

The callback uses the API key from the SDK's server configuration.

## Verify uploads

1. Take a new photo in qb-phone and open it in the gallery.
2. Check for the PNG under `qb-phone` in the [CDN object browser](https://docs.fivemesh.io/cdn/object-browser.md) and open its public URL.
3. Take a second photo and confirm both entries still open.

If the gallery stays empty, check the FiveM server console for an SDK error. Confirm the capture and SDK resources started, the configured key has `cdn:write`, and the key allows the destination path and `image/png`.


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