Hi,
currently uploading all policies with the API (thx for the nice feature). How can I also upload images like the frontend does and let them part of the policy? Can’t find any documented endpoint within the API. If I upload images with the editor, the images won’t be shown in the comment and attachment section. Is there another hidden section?
Kind Regards
Mathias
sam
February 5, 2025, 10:04am
2
Hello Mathias,
Unfortunately, this has not been handled, so it is not possible.
Regards,
Sam
Is there a way around? … uploading it as attachment and then referencing the image url within the policy html content?
are you going to open a bug or feature request? The api for policy uploading is missing an essential feature.
I found a workaround.
You can upload an attachment via API or UI and then reference the picture within the HTML code of the Policy:
Example:
View: {{baseUrl}}/api/security-policies/:id/attachments
{
"success": true,
"data": [
{
"id": 4,
"model": "SecurityPolicies",
"foreign_key": 35,
"name": "1Gesamtskript.pdf",
"filename": "58ca6bee-5bd1-4a4b-b373-f2a213f14742.pdf",
"extension": "pdf",
"mime_type": "application/pdf",
"file_size": 634303,
"user_id": 2,
"created": "2025-02-04T17:06:36+01:00"
},
{
"id": 6,
"model": "SecurityPolicies",
"foreign_key": 35,
"name": "A_6010509.jpg",
"filename": "6a8aa4f4-4552-4a16-9e08-d0c1716e743c.jpg",
"extension": "jpg",
"mime_type": "image/jpeg",
"file_size": 3805080,
"user_id": 2,
"created": "2025-02-06T16:19:45+01:00"
}
],
"pagination": {
"page_count": 1,
"current_page": 1,
"has_next_page": false,
"has_prev_page": false,
"count": 2,
"total_count": 2,
"per_page": 10
}
}
if you want to show the Attachment named A_6010509.jpg you only have to add the following code to the policy:
<img src="/attachments/attachments/download/6" style="width:790.390625px;">
where the number 6 comes from the json “id” field.
2 Likes