Manage User Pictures
Use the functions described below to list, insert and delete user pictures on the access terminal. Note that these actions are unnecessary when operating in any online mode, except for users in contingency mode access.
Get user's photo
Gets the photo of a user specified by his id. The HTTP method used is GET. The contentType is image/jpeg. All parameters are sent via the query string.
GET /user_get_image.fcgi
Parameters
- user_id (int 64): Identifier of the user whose photo will be taken.
Response
- User image in jpg.
Request Example
This request returns the photo of the specified user.
$.ajax({
url: "/user_get_image.fcgi?user_id=123&session=" + session,
type: 'GET',
contentType: 'image/jpeg',
});
Get Photo List
Gets the list of ids of users who own photos, implemented from firmware version 3.10.0 and above. The HTTP method used is POST.
GET /user_list_images.fcgi
Parameters
- This request has no parameters.
Response
- user_ids (int 64 array): ids of the users that have photos.
Request Example
This request will list the ids of the users who have photos.
$.ajax({
url: "/user_list_images.fcgi?session=" + session,
type: 'POST',
contentType: 'application/json'
});
Example of a response
{"user_ids":[1,2,3,4,5,6]}
Insert user photo
Saves the photo of a user specified by its id. Unlike the vast majority of commands in this API, in this command, the Content-Type is necessarily application/octet-stream. Therefore, the image is passed in the Content of the POST method, and the user id is passed in the Query String. The size of the photo must be less than 1MB.
POST /user_set_image.fcgi
Parameters
- user_id (int 64): Identifier of the user whose photo will be assigned. This parameter is passed in the query string.
Response
- This request has no responses.
Request Example
This request will set a new photo for the user
$.ajax({
url: "/user_set_image.fcgi?user_id=123&session=" + session,
type: 'POST',
contentType: 'application/octet-stream',
data: [bytes of the image sent]
});
Insert Photo List
This endpoint inserts a large number of users' photos. Remember that the access has a limit of 1MB per request. It receives an array of ids and images.
POST /user_set_image_list.fcgi
Parameters
- user_images (array): This parameter should be represented as a JSON object containing the members user_id and image (the image in base 64).
Response
- This request has no responses.
Request Example
This request will assign photos to users X and Y.
$.ajax({
url: "/user_set_image_list.fcgi?session=" + session,
type: 'POST',
contentType: 'application/json',
data: {
user_images:
[
{user_id: <user id X>, image: <user image on base 64>},
{user_id: <user id Y>, image: <user image on base 64>}
]
}
});
Delete user photo
Deletes the photo of a user specified by his id, an array of ids, or an "all" flag to remove all. The HTTP method used is POST.
POST /user_destroy_image.fcgi
Parameters
- user_id (int 64): Identifier of the user whose photo will be destroyed.
- user_ids (array int 64): Array of user id's whose pictures will be removed.
- dangling (bool): If set to 'true' removes photos not linked to users.
- all (bool): If set to 'true' all users will have their photos deleted.
Response
- This request has no responses.
Request Example
Removes the photo of the user with id 123.
$.ajax({
url: "/user_destroy_image.fcgi?session=" + session,
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({
user_id: "123"
})
});