Closed Gianfranco97 closed 6 years ago
You must request it via the Document itemtype
@ajsb85 Yes I know, but I still need the id of the document.
Curently the REST API does not allows to get the user picture.
I think we can workaround until the API satisfies this need.
Here is the HTML code to get the user picture when we use the GLPI UI
<img class="user_picture_small" alt="Image" src="/glpi-flyvemdm-92/front/document.send.php?file=_pictures/f2/2_5a6b3e06acef2_min.jpg">
Take inspiration from this, and inspect in the GLPI UI how is built the cookie. I know the session token is the value used in the cookie. Then, you can build a cookie for the above mentioned request and you can download the raw picture.
`${url_base_api}/initSession`
// Store: ${session_token}
`${url_base_api}/getGlpiConfig`
// Store: ${url_base} & ${url_base_api}
`${url_base_api}/User/:id`
// Store: ${picture}
// Generate Thumbnail URL with the suffix _min.jpg
// Store: ${picture_thumbnail}
fetch(`${url_base}`, {
method: 'HEAD'
})
// Change the value of the cookie with start in glpi_ with the ${session_token}
fetch(`${url_base}/front/document.send.php?file=_pictures/a5/${picture}`, {
method: 'GET',
credentials: 'same-origin'
})
fetch(`${url_base}/front/document.send.php?file=_pictures/a5/${picture_thumbnail}`, {
method: 'GET',
credentials: 'same-origin'
})
Expected behavior:
It is necessary to get a way to render the profile images of the user in the dashboard. For the avatar in the list use this format: https://dev.flyve.org/glpi/front/document.send.php?file=_pictures/24/221_5a084effc6624_min.jpg
For the avatar in the user page us this format: https://dev.flyve.org/glpi/front/document.send.php?file=_pictures/24/221_5a084effc6624.jpg
There is a problem with these links and it is the lack of a session cookie in the request. This has a format similar to the following:
This is returned by the backend at the time of making a login
Reference: https://github.com/flyve-mdm/web-mdm-dashboard/issues/20