CDN uploads
Configure FiveManage or Qbox CDN and use the bridge's server upload exports.
Bridge 1.2.1 supports the provider names fivemanage and qbox. Each resource selects a provider when it calls the bridge's server exports.
Set an API key
Create an API key in FiveManage or the Qbox dashboard. Set the key's permissions and folder access for the file types your resource uploads.
Add the matching key before the bridge's ensure line. Use set so the key stays server-only.
set 402studio_bridge:fivemanageKey "YOUR_FIVEMANAGE_KEY"
set 402studio_bridge:qboxKey "YOUR_QBOX_CDN_KEY"
ensure 402studio_bridgeKeep API keys in your private server configuration. The bridge uses the key in a server HTTP request and returns a temporary upload URL to the calling resource.
Request an upload URL
Call CreateCdnUpload from a server thread or handler that can yield:
local target, errorCode = exports['402studio_bridge']:CreateCdnUpload('qbox')
if not target then
print(('Upload setup failed: %s'):format(errorCode))
return
end| Returned field | Value |
|---|---|
target.provider | The selected provider name |
target.url | Temporary HTTPS upload URL |
target.formField | Multipart file field, file for both included providers |
Pass target.url and target.formField to your resource's multipart uploader. The temporary URL authorizes that upload. Upload promptly and request a fresh URL when it expires.
Presigned requests time out after 10 seconds. FiveManage upload URLs expire five minutes after the bridge requests them.
Resolve a completed upload
When your server upload callback completes, pass its result to ResolveCdnUpload using the same provider:
local file, errorCode = exports['402studio_bridge']:ResolveCdnUpload('qbox', result)
if not file then
print(('Upload result rejected: %s'):format(errorCode))
return
endThe result table contains status = 'success' and the provider's JSON response in response. The provider response contains status = 'ok' and data.url. The bridge accepts that response as a Lua table or JSON string.
The returned file.url is the hosted HTTPS file URL. file.id contains the provider's file ID when supplied. Save the URL with your resource's own record and player identifier when building a media library. File availability follows the provider's storage and retention settings.
Server exports
| Export | Result |
|---|---|
IsCdnAvailable(provider) | true when the provider adapter is registered, otherwise false, errorCode |
CreateCdnUpload(provider) | { provider, url, formField } or nil, errorCode |
ResolveCdnUpload(provider, result) | { url, id } or nil, errorCode; id is optional |
IsCdnAvailable checks the adapter registration. CreateCdnUpload checks the configured key and contacts the provider. All three exports use the bridge's resource access rules.
Upload errors
| Error | What to check |
|---|---|
forbidden_resource | Allow the calling resource in the bridge configuration |
invalid_cdn_provider | Pass a provider name as a non-empty string |
cdn_unavailable | Use fivemanage or qbox with Bridge 1.2.1 |
cdn_key_missing | Set the matching server-only key convar |
cdn_request_failed | Check the key permissions, provider availability, and account limits |
cdn_timeout | The provider request exceeded 10 seconds; retry when the service is available |
invalid_cdn_response | Check the upload result shape and the HTTPS file URL |