Skip to content

Video Records

1. Request video clip lists.

Video clips are recorded as long as devices are powered on. The clips are stored in the SD card of the device and synced to the cloud storage once the device is connected online. Clients that have joined the room in the socket.io server (see part b of the previous section.) are capable of fetching the synced clip lists via emitting the "getRecList" event and writing the "recList" event handler.

socket.emit("getRecList");
socketio.on("recList", (list) => {
    setRecList(list);
});
The argument of the "recList" event handler is expected to be the list of video clip names of the device which you are in the socket.io room with.

2. Get video clips.

Video clips listed in the payload of "recList" event handler are to be accessed and downloaed via the presigned link generated by requesting "POST" to this API. The headers and body of the "POST" request is expected to follow the json form of:

const headers = {
    Content-Type: "application/json",
    token: accessToken
};
const body = {
    device: "tj01",
    recFile: "2022-08-01T12:03:01.mp4"
}
The accessToken in the code block is acquired by requesting "POST" to the token API. The payload form is:
const headers = {
    Content-Type: "application/json"
};
const body = {
    name: "username",
    password: "password"
}
The username and password above are to be replaced with your own registry information. If you have posted the right authentication, the return code would carry the payload that containing the access token which you should attach to headers of presigned url requesting.
{
    message: "Authenticated.",
    success: true,
    token: "accessToken"
}
And the successful request to the getPresignedUrl API return the payload of:
{
    message: "Presigned URL generated.",
    success: true,
    presignedUrl: "temporaryClipDownloadLink"
}