Uploading an image
If you wish to upload an image to the Image API, you can do so by sending a POST request to the https://api.fivemanage.com/api/image (opens in a new tab) endpoint.
General
Headers
You need to send an Authorization
header with your API key.
Query parameters
You can also send your API key as a query parameter ?apiKey=
. This is useful if you are using the Image API in a browser.
Body
The body of the request should be a form-data object with a file named image
.
Examples
const axios = require('axios');
const fs = require('fs');
const apiKey = 'YOUR_API_TOKEN';
const url = 'https://api.fivemanage.com/api/image';
const formData = new FormData();
formData.append('image', fs.createReadStream('image.png'));
// Optional metadata field (JSON string)
formData.append("metadata", JSON.stringify({
name: 'My image',
description: 'This is my image',
}));
axios.post(url, formData, {
headers: {
Authorization: apiKey,
}
}).then(res => {
console.log(res.data.url);
}).catch(err => {
console.error(err);
});
FiveM
There are a few ways to upload an image to the Image API. The easiest way is to use Screenshot Basic (opens in a new tab).
Screenshot Basic
Using headers
exports['screenshot-basic']:requestScreenshotUpload('https://api.fivemanage.com/api/image',
'image',
{
headers = {
Authorization = "YOUR_API_TOKEN"
}
},
function(data)
local resp = json.decode(data)
if resp then
print(resp.url)
end
end)
Using query parameters
exports['screenshot-basic']:requestScreenshotUpload('https://api.fivemanage.com/api/image?apiKey=YOUR_API_TOKEN', 'image', function(data)
local resp = json.decode(data)
if resp then
print(resp.url)
end
end)