Guide · Integrations
## With a header
```lua
exports['screenshot-basic']:requestScreenshotUpload(
'https://your-instance/api/v1/uploads',
'file',
{ headers = { Authorization = 'YOUR_TOKEN' } },
function(data)
local response = json.decode(data)
if response.status == 'ok' then
print(response.data.url)
else
print('upload failed: ' .. response.error.code)
end
end
)
```
## Without a header
Older builds of `screenshot-basic` cannot set headers on the upload. The token
is accepted in the query string for exactly that case.
```lua
exports['screenshot-basic']:requestScreenshotUpload(
'https://your-instance/api/v1/uploads?apiKey=YOUR_TOKEN',
'file',
function(data)
print(json.decode(data).data.url)
end
)
```
A key in a URL ends up in more logs than a key in a header. Use the header form
when your build supports it, and give this token only `upload-image`.
## Reading the failure
Branch on `response.error.code`, never on the message. The codes are stable and
never translated; the messages are English prose for a human reading a log.
The ones you will actually meet:
| Code | What to do |
| ------------------------ | --------------------------------------------------------------- |
| `invalid_token` | The key is wrong. Check for a copied space |
| `token_revoked` | The key was deliberately turned off. Ask for a new one |
| `insufficient_scope` | The key cannot upload this kind |
| `quota_exceeded` | The organisation is full. Nothing the script can fix |
| `rate_limited` | Back off for the seconds in `error.details.retry_after_seconds` |
| `unsupported_media_type` | Whatever was captured is not an accepted format |
screenshot-basic
Uploading directly from a FiveM resource.
With a header
Lua
exports['screenshot-basic']:requestScreenshotUpload(
'https://your-instance/api/v1/uploads',
'file',
{ headers = { Authorization = 'YOUR_TOKEN' } },
function(data)
local response = json.decode(data)
if response.status == 'ok' then
print(response.data.url)
else
print('upload failed: ' .. response.error.code)
end
end
)Without a header
Older builds of screenshot-basic cannot set headers on the upload. The token
is accepted in the query string for exactly that case.
Lua
exports['screenshot-basic']:requestScreenshotUpload(
'https://your-instance/api/v1/uploads?apiKey=YOUR_TOKEN',
'file',
function(data)
print(json.decode(data).data.url)
end
)A key in a URL ends up in more logs than a key in a header. Use the header form
when your build supports it, and give this token only upload-image.
Reading the failure
Branch on response.error.code, never on the message. The codes are stable and
never translated; the messages are English prose for a human reading a log.
The ones you will actually meet:
| Code | What to do |
|---|---|
invalid_token |
The key is wrong. Check for a copied space |
token_revoked |
The key was deliberately turned off. Ask for a new one |
insufficient_scope |
The key cannot upload this kind |
quota_exceeded |
The organisation is full. Nothing the script can fix |
rate_limited |
Back off for the seconds in error.details.retry_after_seconds |
unsupported_media_type |
Whatever was captured is not an accepted format |