Skip to main content
This is the manual, interim version. A payload-storage-pixglory adapter package, implementing Payload’s standard cloud-storage plugin interface, is planned next. Until it ships, this guide is how you wire a Payload upload collection to PixGlory yourself: a beforeChange hook that presigns and confirms through the machine API. When the adapter ships, it replaces this collection config with a few lines of plugin configuration; nothing about your stored data changes, since it will still be a url field pointing at a cdn.pixglory.com link.

Before you start

You need a PixGlory API key and a CDN project. See the Quickstart to create a key, and create a project from your dashboard if you don’t have one yet. Set both as environment variables Payload’s server can read:
.env
Find your project’s id with a request against GET /v1/projects:

The collection

Set disableLocalStorage: true so Payload never writes the file to its own disk, and add a beforeChange hook that uploads to PixGlory instead. The trick that keeps the read side simple: override Payload’s own url field with the file’s real PixGlory link, so every place your app already reads doc.url keeps working unchanged, with no custom static route to serve it.
collections/Media.ts
Use it in your app the same way you’d use any other upload collection’s document:

What this interim version does not do

Deleting the Payload document does not delete the file from PixGlory. The machine API has no delete or lookup-by-id route yet (GET/DELETE /v1/files/{id} is plan-24 slice 2a, not shipped), so an afterDelete hook here has nothing to call. Until that ships, deleting media in Payload only removes the Payload record; the file stays in your CDN project and you’d remove it from the dashboard by hand if you want it gone. This gap, plus a filename-keyed lookup, is exactly what the official adapter needs to implement handleDelete correctly, which is why it’s built before the adapter package rather than guessed at. Re-uploading a replacement image creates a new file rather than replacing one in place. The machine API’s replace operation addresses a file by the id PixGlory assigned it, which this collection never stores. That’s a reasonable thing to add to pixgloryPath above if you need it before the adapter ships; the adapter itself will handle it as part of handleUpload.

Handling errors

A 402 response means the organisation’s storage quota would be exceeded; a 429 means you’ve hit the rate limit and should back off using the Retry-After header. Every error body has the same shape:
Branch on error.code, not error.message, which can change wording without notice. The full list of status codes and error codes is in the API Reference tab. Throwing inside the beforeChange hook above (as the presign/confirm failure checks do) fails the whole create operation, so a customer never ends up with a Payload document that has no file behind it.