The REST API allows you to make an operation on a video form data. API link: https://hng5.akinlua.repl.co/
The Video API provides a RESTful interface that allows a post request of a video form data and then stores the video in a disk and sends a response containing neccesary informations about the video inlcuding the video src path that can be used in the front end to display the video
Here are some examples on how to use the API:
You can use any application such as Postman to make the requests
POST /api/upload
Content-Type: multipart/form-data
| Field Name | Type | Description
| ---------- | ------ |
| chunk | file | Get the chunk from file.slice(start, start + chunksize)
| totalSize| number | Get the file size from file.size
| start | number | Get the value from which the file is sliced, initial 0
| fileName | String | Get the filename from file.name
| fileType | Mimetype| Get the mimetype of the file from file.type
.Response:
{
"error": false,
"status": 200,
"Message": "File Uploaded Successfully",
"originalname": "vlc-record-2022-08-13-22h48m54s-Superstore S03E03 - RMTeam, RMZ.cr-.mp4",
"filename": "Video_1696060225889-vlc-record-2022-08-13-22h48m54s-Superstore S03E03 - RMTeam, RMZ.cr-.mp4",
"Path": "public/upload/Video_1696060225889-vlc-record-2022-08-13-22h48m54s-Superstore S03E03 - RMTeam, RMZ.cr-.mp4",
"videoPath_src": "https://hng5.akinlua.repl.co//upload/Video_1696060225889-vlc-record-2022-08-13-22h48m54s-Superstore S03E03 - RMTeam, RMZ.cr-.mp4",
"transcription": "words of transcript"
}
Content-Type: application/json
If a file is not found
. Body:
{
error: true,
status: 404,
errorMessage: "No File Found"
}
Content-Type: application/json
If the file found is not a video file Only .mp4 is allowed.
. Body:
{
error: true,
status: 400,
errorMessage: "Make sure file is a video file"
}
If the video file is more than 50Mb which is the max size allowed for processing the video.
. Body:
{
error: true,
status: 400,
errorMessage: "Make sure Video file is no more than 50MB"
}
Content-Type: application/json
If there was any other error with the server, you will get the below error
.Body:
{
error: true,
status: 500,
errorMessage: "An error was found"
}