Presigned URLs
Presigned URLs is the safest way to upload files through the client. One example is from NUI in FiveM, where you otherwise would expose the token to every client if you're not using a presigned URL, or uploading your files from the server.
To get a presigned URL, you first need to request for it. Here we'll go through how you'd do it.
Request the presigned URL
Start by performing a GET
request on the server. This needs to contain the endpoint and your API token.
The ?fileType
param can be image
, audio
or video
.
We plan to remove this ?fileType
param in our next version of the API.
curl --request GET \
--url 'https://api.fivemanage.com/api/presigned-url?fileType=image' \
--header 'Authorization: YOUR_API_TOKEN' \
You will then get a response that looks like this:
{
"presignedUrl": "https://api.fivemanage.com/api/presigned-url/iCyMnIkzF423RQr88Hppo"
}
This is the url that you will be using in order to upload the file.
Uploading files
Once you have this URL, you can then use it to upload a file like you might previously have done, but without a Authorization
header.
curl --request POST \
--url https://api.fivemanage.com/api/presigned-url/iCyMnIkzF423RQr88Hppo \
--header 'Content-Type: multipart/form-data' \
--form file=path/to/your/file.png
Response
{"id":"51Q3Uiqv4vERup113MZ0I","url":"https://r2.fivemanage.com/images/FKmUoQUAFkAz.jpg"}