Uploading videos
Getting started
In order to send vidoes to the Video API, you can do so by sending a POST request to the https://api.fivemanage.com/api/video (opens in a new tab) endpoint.
To upload video, simply submit a form with a form field called file
with your video as value. As well as metadata.
Uploading a video
const axios = require('axios');
const fs = require('fs');
const apiKey = 'YOUR_API_TOKEN';
const url = 'https://api.fivemanage.com/api/video';
const formData = new FormData();
formData.append('file', yourVideoBlob);
// Optional metadata field (JSON string)
formData.append("metadata", JSON.stringify({
name: 'My video',
description: 'This is a video of something cool",
// or any other field
}));
axios.post(url, formData, {
headers: {
Authorization: apiKey,
}
}).then(res => {
console.log(res.data.url);
}).catch(err => {
console.error(err);
});
Response
Success
{
"url": "https://r2.fivemanage.com/video/1234567890",
"id": "0987654321"
}
Deleting a video
When we want to delete a video, we can do so by sending a DELETE request to the https://api.fivemanage.com/api/video/:id (opens in a new tab) endpoint.
The :id
parameter should be the ID of the video you want to delete. You can get the ID from the response when you upload a video (see above).
import axios from "axios";
const options = {
method: 'DELETE',
url: 'http://api.fivemanage.com/api/video/delete/0987654321',
headers: {
Authorization: 'YOUR_API_TOKEN'
}
};
axios.request(options).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.error(error);
});