Files
Introduction
Eagle Eye Networks users can archive part of their recorded videos in the archive storage associated with their account. Archived videos are protected from being overwritten by the system according to the retention time configuration. Using the /files API, you can access a list of archived files, and, if necessary, rename, move, and delete them.
Before you begin
Getting a list of the archived files
By calling the GET
/files endpoint you can retrieve a list of the available files and folders in the archive storage.
curl --location 'https://<base-URL>/api/v3.0/files' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <access-token>'
The response to the above request is the following:
{
"nextPageToken": "",
"prevPageToken": "",
"results": [
{
"id": "4272a107-a9f1-4f45-bc95-3882a285205c",
"mimeType": "application/directory",
"directory": "/",
"name": "Test"
},
{
"id": "36230c7b-f827-49b8-a76a-d8620f899dae",
"mimeType": "video/mp4",
"directory": "/",
"name": "Video CAM 1 2023-05-22 15-10-39.mp4"
},
{
"id": "2c236d24-79e3-44d5-adeb-4d370221217d",
"mimeType": "video/mp4",
"directory": "/Test",
"name": "Video CAM 1 2023-05-22 15-10-39.mp4"
}
]
}
By using the /files/{id} endpoint it is possible to get detailed information about a specific ID.
curl --location '<base-URL>/api/v3.0/files/<ID>?include=publicShare&include=createTimestamp' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <access-token>'
Note
You can retrieve more information about a file by including different parameters. To maximize the performance and minimize the response time, it is recommended to limit the parameters you include.
Deleting a File
To delete a file or folder make a DELETE
call to the /files/{id} endpoint:
curl --location --request DELETE 'https://<base-URL>/api/v3.0/files/<ID>' \
--header 'Authorization: Bearer <access-token>'
Downloading a File
To download a file add the alt=media
parameters to the /files/{id}
endpoint as shown below:
curl --location 'https://<base_URL>/api/v3.0/files/<ID>?alt=media' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <access-token>'
--output <local-path>\<file-name>.mp4
If you run the above request by CURL, the media file is downloaded to the <local-path>
with .mp4
extension.
Uploading a File
Uploading a file to the archive storage is a multi-step process. To start, you need to make a POST
request to the /files endpoint. In the request body, you'll need to include the name of the file with the file extension included. Optionally, you can include the directory
parameter to specify the folder where the file will be uploaded or the mimeType
parameter to explicitly specify the type of the file.
curl --request POST \
--url https://api.cxxx.eagleeyenetworks.com/api/v3.0/files \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"mimeType": "video/mp4",
"directory": "/uploads",
"name": "Video CAM 1 2023-05-22 15-10-39.mp4"
}
'
If successful, the response to the above will include the id
of the newly created file. You can then use this id
to find the uploadUrl
of the file by sending a request to the /files/{file_id} endpoint. You'll need to set the include
parameter to uploadUrl
in the request.
curl --request GET \
--url 'https://api.cxxx.eagleeyenetworks.com/api/v3.0/files/36230c7b-f827-49b8-a76a-d8620f899dae?include=uploadUrl' \
--header 'accept: application/json'
Once you have the uploadUrl
, you can use it to upload the file to the archive storage.
curl --upload-file 'Video CAM 1 2023-05-22 15-10-39.mp4' 'https://een-drivefs-c025.s3.amazonaws.com/....'
Renaming and Moving a File or a Folder
The following example of a PUT
request shows how to rename/move a file or folder. You need to make a PUT
request with the detailed /files/<ID>
endpoint for this purpose.
curl --location --request PUT 'https://<base_URL>/api/v3.0/files/36230c7b-f827-49b8-a76a-d8620f899dae' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <access-token>' \
--data '{
"id": "f2d4ad7b-bada-4c44-9f70-9c4b85e46b7d",
"mimeType": "video/mp4",
"directory": "/test folder5",
"name": "Video CAM 1 2023-06-01 14-37-13.mp4"
}'
As shown above, you can change the name of a file or folder. You can also use the same name, but a different directory
value to move the file or folder. If the directory does not exist, it is automatically created and the move operation is performed.
Note
The history browser of the VMS allows users to save video files to the archive folder. Directly uploading or creating video files from the API is not possible at the moment.
Updated 5 months ago