Hi all, I wonder whether it is - or will be - possible to upload images (e.g., logos) using an API call. I can imagine two options:
passing an image as a BLOB to a specific datafield. I’ve seen that there is an option in the Q&A to upload an image, which places the (binary) image data in a text-type datafield. Is something like this also possible when assembling a document using an API POST request?
uploading an image in a specific folder, unrelated to the assembly of a specific document.
In other words: can using images in documents be automated?
I would need to double-check (never tried this before), but your first option should be possible indeed. Just try passing the B64 to the datafield in your API call.
The second one is not currently possible, because we don’t currently offer any clause-upload facilities or image-upload facilities. It could be added (internally everything uses a kind of API already, so it’s mostly a matter of exposing the internal API), but we haven’t had the question earlier.
I just tried with a random example, and it did seem to work correctly on my end.
Just a hunch, but
can you check whether your B64 image starts with the typical B64 MIME header (some “data:image/jpeg;base64,” if it’s a JPEG; “data:image/png;base64,” for a PNG)
you are wrapping the datafield in a @image(…), right?
Hi Maarten,
It was the MIME header that was missing. I just needed to add it when converting the image to base64: IMG="data:image/jpeg;base64,$(base64 logo.png)"