Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.sacul.cloud/llms.txt

Use this file to discover all available pages before exploring further.

LB Scripts Integration

To use sCloud with LB-Phone or LB-Tablet, you need to configure the scripts to use custom upload method. If you use both scripts or have multiple FiveM servers, we recommend you to either use different buckets or organize your files in a specific folder.
sCloud CDN provides a custom bucket type made for LB-Scripts, when creating your bucket, select LB-Scripts as the bucket type.This ensure that your bucket and our API are optimized for LB-Scripts and your players.

Prerequisites

First, you need to create a bucket if not already done, you can do so by heading to sCloud CDN Dashboard. Use the following details to configure the custom upload method:
  • Upload URL: https://cdn.sacul.cloud/YOUR_BUCKET_NAME
  • Field Name: file
  • Headers:
    • Authorization: Bearer YOUR_API_KEY
Replace YOUR_BUCKET_NAME and YOUR_API_KEY with your actual sCloud credentials. You can find your API key in your sCloud CDN Dashboard.

Configuration

LB-Phone Configuration

To use presigned uploads with LB-Phone, follow these steps:
  1. Server API Keys & Buckets: Open lb-phone/server/apiKeys.lua and configure your API keys and bucket names.
    API_KEYS = {
        Video = "YOUR_API_KEY",
        Image = "YOUR_API_KEY",
        Audio = "YOUR_API_KEY",
    }
    
    BUCKET_NAMES = {
        Video = "YOUR_BUCKET_NAME",
        Image = "YOUR_BUCKET_NAME",
        Audio = "YOUR_BUCKET_NAME",
    }
    
  2. Server Functions: Update lb-phone/server/custom/functions/functions.lua to implement the GetPresignedUrl function.
    function GetPresignedUrl(source, uploadType)
        local apiKey = API_KEYS[uploadType]
        local bucketName = BUCKET_NAMES[uploadType]
    
        if not apiKey or not bucketName then
            infoprint("error", ("[GetPresignedUrl] Invalid uploadType '%s' (missing API key or bucket)"):format(uploadType))
            return false
        end
    
        local p = promise.new()
    
        PerformHttpRequest(
            ("https://cdn.sacul.cloud/api/presigned-url?randomizeName=true&bucketName=%s"):format(bucketName),
            function(status, body, headers, error)
                if status ~= 200 then
                    infoprint("error", ("[GetPresignedUrl] Request failed for '%s', status: %s"):format(uploadType, status))
                    p:resolve(false)
                    return
                end
    
                local ok, data = pcall(json.decode, body)
                if not ok or not data or not data.success or not data.url then
                    infoprint("error", ("[GetPresignedUrl] Invalid response for '%s'"):format(uploadType))
                    p:resolve(false)
                    return
                end
    
                p:resolve(data.url)
            end,
            "GET",
            nil,
            { ["Authorization"] = apiKey }
        )
    
        return Citizen.Await(p)
    end
    
  3. Shared Upload Config: In lb-phone/shared/upload.lua, set the url to "PRESIGNED_URL" for your custom methods.
    UploadMethods = {
        Custom = {
            Video = {
                url = "PRESIGNED_URL",
                -- ... other settings
            },
            Image = {
                url = "PRESIGNED_URL",
                -- ... other settings
            },
            Audio = {
                url = "PRESIGNED_URL",
                -- ... other settings
            },
        }
    }
    
  4. Client Functions: Finally, ensure CustomGetUploadMethod is implemented in lb-phone/client/custom/functions/functions.lua.
    ---@param uploadType "Video" | "Image" | "Audio"
    ---@return UploadMethod?
    function CustomGetUploadMethod(uploadType)
        local methods = UploadMethods[Config.UploadMethod[uploadType]]
        if not methods then
            infoprint("error", "Upload methods not found for ", uploadType)
            return
        end
    
        ---@type UploadMethod?
        local method = methods[uploadType] or methods.Default
        if not method then
            infoprint("error", "Upload method not found for ", uploadType)
            return
        end
    
        return method
    end
    

LB-Tablet Configuration

Configuration for LB-Tablet is similar to LB-Phone:
  1. Server API Keys & Buckets: Open lb-tablet/server/apiKeys.lua.
    API_KEYS = {
        Video = "YOUR_API_KEY",
        Image = "YOUR_API_KEY",
        Audio = "YOUR_API_KEY",
    }
    
    BUCKET_NAMES = {
        Video = "YOUR_BUCKET_NAME",
        Image = "YOUR_BUCKET_NAME",
        Audio = "YOUR_BUCKET_NAME",
    }
    
  2. Server Functions: Update lb-tablet/server/custom/functions/functions.lua to implement GetPresignedUrl. (The logic is identical to the one in LB-Phone).
  3. Config Upload: In lb-tablet/config/upload.lua, set url = "PRESIGNED_URL".
  4. Client Functions: Implement CustomGetUploadMethod in lb-tablet/client/custom/functions/functions.lua.

Legacy Configuration

This documentation is deceprated, using the following upload method can and will expose your bucket API Key.

LB-Phone Configuration

First, open the main LB-Phone configuration file in lb-phone/config/config.lua and scroll down to Config.UploadMethod to set the following values.
Config.UploadMethod.Video = "Custom"
Config.UploadMethod.Image = "Custom"
Config.UploadMethod.Audio = "Custom"
Optionnaly, you can edit the following configuration
Config.Video = {}
Config.Video.Bitrate = 500
Config.Video.FrameRate = 24
Config.Video.MaxSize = 50
Config.Video.MaxDuration = 120

Config.Image = {}
Config.Image.Mime = "image/webp"
Config.Image.Quality = 0.95
Next, head to lb-phone/shared/upload.lua and replace the default configuration with the following.
UploadMethods = {
    Custom = {
        Video = {
            url = "https://cdn.sacul.cloud/YOUR_BUCKET_NAME",
            field = "file",
            headers = {
                ["Authorization"] = "YOUR_API_KEY"
            },
            error = {
                path = "success",
                value = false
            },
            success = {
                path = "url"
            },
            suffix = "",
        },
        Image = {
            url = "https://cdn.sacul.cloud/YOUR_BUCKET_NAME",
            field = "file",
            headers = {
                ["Authorization"] = "YOUR_API_KEY"
            },
            error = {
                path = "success",
                value = false
            },
            success = {
                path = "url"
            },
            suffix = "",
        },
        Audio = {
            url = "https://cdn.sacul.cloud/YOUR_BUCKET_NAME",
            field = "file",
            headers = {
                ["Authorization"] = "YOUR_API_KEY"
            },
            error = {
                path = "success",
                value = false
            },
            success = {
                path = "url"
            },
            suffix = "",
        },
    }
}
And that’s it! You have successfully configured LB-Phone to use sCloud CDN.

LB-Tablet Configuration

First, open the main LB-Tablet configuration file in lb-tablet/config/config.lua and scroll down to Config.UploadMethod to set the following values.
Config.UploadMethod.Video = "Custom"
Config.UploadMethod.Image = "Custom"
Config.UploadMethod.Audio = "Custom"
Optionnaly, you can edit the following configuration
Config.Video = {}
Config.Video.Bitrate = 500
Config.Video.FrameRate = 24
Config.Video.MaxSize = 50
Config.Video.MaxDuration = 120

Config.Image = {}
Config.Image.Mime = "image/webp"
Config.Image.Quality = 0.95
Next, head to lb-tablet/config/upload.lua and replace the default configuration with the following.
UploadMethods = {
    Custom = {
        Video = {
            url = "https://cdn.sacul.cloud/YOUR_BUCKET_NAME",
            field = "file",
            headers = {
                ["Authorization"] = "YOUR_API_KEY"
            },
            error = {
                path = "success",
                value = false
            },
            success = {
                path = "url"
            },
            suffix = "",
        },
        Image = {
            url = "https://cdn.sacul.cloud/YOUR_BUCKET_NAME",
            field = "file",
            headers = {
                ["Authorization"] = "YOUR_API_KEY"
            },
            error = {
                path = "success",
                value = false
            },
            success = {
                path = "url"
            },
            suffix = "",
        },
        Audio = {
            url = "https://cdn.sacul.cloud/YOUR_BUCKET_NAME",
            field = "file",
            headers = {
                ["Authorization"] = "YOUR_API_KEY"
            },
            error = {
                path = "success",
                value = false
            },
            success = {
                path = "url"
            },
            suffix = "",
        },
    }
}
And that’s it! You have successfully configured LB-Tablet to use sCloud CDN.