Skip to main content

LB Phone

This guide will go over how to set up the Qbox CDN with LB Phone

Whitelisting the CDN Domain

First we'll need to whitelist the qbox domain. Navigate to config > config.lua and search for the following Config.UploadWhitelistedDomains. In this table you'll need to add qbox.re to the list of domains. It should look like this:

-- Set to false/empty to disable
Config.UploadWhitelistedDomains = { -- domains that are allowed to upload images to the phone (prevent using devtools to upload images)
"fivemanage.com",
"fmfile.com",
"qbox.re",
"cfx.re" -- lb-upload
}

Changing upload method

In the same config file we will search for Config.UploadMethod. This will give you 3 different options for all the file types. Change them all to qbox like so:

Config.UploadMethod.Video = "Qbox" -- "Fivemanage" or "LBUpload" or "Custom"
Config.UploadMethod.Image = "Qbox" -- "Fivemanage" or "LBUpload" or "Custom"
Config.UploadMethod.Audio = "Qbox" -- "Fivemanage" or "LBUpload" or "Custom"

Adding the Qbox upload method

Now we are done in the config file. Next we will go to shared > upload.lua. Here you will see a big table with all kinds of upload methods for different services. We will be adding one for Qbox in here.

danger

Add this inside the UploadMethods table, alongside all the other options!

Qbox = {
Default = {
url = "PRESIGNED_URL",
field = "file",
success = {
path = "data.url"
},
sendPlayer = "metadata"
},
},
This is what your complete table would look like

Adding your API key

Navigate to server > apiKeys.lua. Here you will see a table with all the API keys for the different upload methods. Simply add the same API key that you generated in the Qbox CDN dashboard.

API_KEYS = {
Video = "API_KEY_HERE",
Image = "API_KEY_HERE",
Audio = "API_KEY_HERE",
}

Editing Presigned URL Function

And lastly we will go to server > custom > functions > functions.lua. This file contains the function GetPresignedUrl which we will replace with the following:

function GetPresignedUrl(source, uploadType)
if not uploadType then
debugprint("GetPresignedUrl: Missing uploadType")
return nil
end

local apiKey = API_KEYS[uploadType]

if not apiKey or apiKey == "" then
debugprint("GetPresignedUrl: Missing API key for uploadType", uploadType)
return nil
end

local requestPromise = promise.new()

PerformHttpRequest("https://api.qbox.re/v1/file/presigned-url", function(statusCode, result)
local presignedUrl

if statusCode == 200 then
local ok, response = pcall(json.decode, result)

if ok and response and response.data and response.data.presignedUrl then
presignedUrl = response.data.presignedUrl
else
debugprint("GetPresignedUrl: Invalid response payload", result)
end
else
debugprint("GetPresignedUrl: Request failed", statusCode, result)
end

requestPromise:resolve(presignedUrl)
end, "GET", json.encode({ uploadType = uploadType }), {
["Content-Type"] = "application/json",
["Authorization"] = apiKey,
})

return Citizen.Await(requestPromise)
end