A FiveM script to generate presigned URLs for uploading files to S3.
To use Cloudflare R2, add the following convars to your server.cfg:
set LB_R2_BUCKET bucket_name
set LB_R2_ACCOUNT_ID account_id
set LB_R2_ACCESS_KEY_ID access_key_id
set LB_R2_SECRET_ACCESS_KEY secret_access_key
set LB_R2_DOMAIN r2.example.comYou can get your tokens at https://developers.cloudflare.com/r2/api/tokens
To use AWS S3, add the following convars to your server.cfg:
set LB_S3_BUCKET bucket_name
set LB_S3_REGION region
set LB_S3_ACCESS_KEY_ID access_key_id
set LB_S3_SECRET_ACCESS_KEY secret_access_key
set LB_S3_DOMAIN s3.example.com # optionalYou can get your tokens at https://aws.amazon.com/s3/
- Download the latest release from the releases page
- Add the script to your
resourcesfolder - Add
start lb-presignedto yourserver.cfg - Configure your credentials as described above
- Start your server, or run
refreshandensure lb-presignedin your server console
GeneratePresignedUrl(mimeType: string): { presignedUrl: string, fileUrl: string }
local result = exports["lb-presigned"]:GeneratePresignedUrl("image/webp")
print(result.presignedUrl) -- URL to upload the file
print(result.fileUrl) -- URL to access the file after it's uploadedImportant
This requires LB Tablet v1.6.0 or higher.
- Install & configure LB Presigned as described above
- Set all
Config.UploadMethodtoLBPresigned - Restart your server, or run
ensure lb-tabletin your server console
Important
This requires LB Phone v2.5.5 or higher.