Attachment Export
For records that support attachments, you can display the list of attachments as follows:
/c/firma/adresar/12/prilohy
The metadata of a specific attachment can be retrieved in the usual way:
/c/firma/adresar/12/prilohy/75
The binary data of an attachment can be retrieved using GET; the response also includes the correct Content-Type header:
/c/firma/adresar/12/prilohy/75/content
If the attachment is an image, a thumbnail can be retrieved in a similar way (if it does not exist, the response will be a 404 error):
/c/firma/adresar/12/prilohy/75/thumbnail
Binary File Import
An attachment can also be created via PUT; you must specify the filename and send its type in the Content-Type header:
PUT /c/firma/adresar/12/prilohy/new/název souboru
Content-Type: image/jpeg
The binary data of the attachment must be included in the request body. An existing attachment cannot be modified; in such a case, the attachment must be deleted and re-created. Details on importing attachments via XML are provided below.
Import via XML/JSON
Importing attachments via XML is also supported (data must again be Base64-encoded), but there are certain limitations:
a new attachment can only be created as part of another object (it cannot be the root tag)
only metadata can be modified; the attachment data itself cannot be changed
Use a different URL endpoint than for binary file import, e.g.: /c/firma/faktura-vydana.xml.
XML Example
<winstrom>
<faktura-vydana>
<id>11925</id>
<prilohy>
<priloha update="ignore">
<id>ext:DPH-KONTROLA:faktura-vydana:11925</id>
<contentType>text/html</contentType>
<nazSoub>vies-CZ18239617-2023-01-19.html</nazSoub>
<typK>typPrilohy.ostatni</typK>
<content encoding="base64">PGh0bWw+PG...</content>
</priloha>
</prilohy>
</faktura-vydana>
</winstrom>
JSON Example
{
"winstrom": {
"faktura-vydana": {
"id": "11925",
"prilohy": {
"priloha": {
"id": "ext:DPH-KONTROLA:faktura-vydana:11925",
"contentType": "text/html",
"nazSoub": "vies-CZ18239617-2023-01-19.html",
"typK": "typPrilohy.ostatni",
"content@encoding": "base64",
"content": "PGh0bWw+PG..."
}
}
}
}
}
Note:
If you import an XML attachment, the API will automatically switch to XML format communication (the JSON header will then be ignored).
Export
Attachment content can also be exported directly to XML; data is exported encoded in Base64 (<?xml version="1.0"?> <content encoding="base64">...</content> ).
When accessing via the REST API, attachments can also be exported as part of the objects they belong to; in that case, the parameter relations=prilohy must be included in the URL.
Image Support
If you upload an attachment in an image format to ABRA Flexi, thumbnail generation support is added. The image must be in one of the following formats:
image/jpeg
image/gif
image/png
For objects with an attachment, you can request the primary image (if it does not exist, the response will be a 404 error):
/c/firma/cenik/12/thumbnail.png
You can specify the image size using the w and h parameters.
Attachments for Settings
The company settings contain two attachments: a logo and a signature and stamp. These are handled in a special way.
To check whether a logo is attached to the settings, use GET:
GET /c/firma/nastaveni/1/logo
If a logo is attached, a redirect to the canonical attachment URL (in the form /c/firma/priloha/3) is returned, i.e., a 303 status code and a Location header. If no logo is attached, a 404 status code is returned.
If no logo is attached, you can attach one by calling PUT or POST (with the correct Content-Type header):
PUT /c/firma/nastaveni/1/logo Content-Type: image/jpeg
The binary data of the logo must be included in the request body as usual. As with attachments, a logo cannot be attached to the settings if one is already attached. In such a situation, a 400 error code is returned. Success is indicated by a 201 status code, and the Location header contains the URL of the newly created attachment.
The logo can be removed using DELETE:
DELETE /c/firma/nastaveni/1/logo
If the logo was successfully removed, a 200 status code is returned. If no logo existed, a 404 error code is returned.
The signature and stamp are handled in exactly the same way, except that instead of the word logo in the URL, podpis-razitko is used (e.g., /c/firma/nastaveni/1/podpis-razitko).
