How to add an inline attachment?

Question on behalf of @rainer-brave-cloud

Dear A12 team,
is there a Java helper class/library to programmatically add an inline attachment (i.e. a file) to an A12 document?

Moin,
you can have a look at the attachment extensions points from dataservices.

https://geta12.com/docs/?release=2022.06#content:asciidoc,product:data_services,artifact:dataservices-documentation-src,scene:Data_Services,anchor:attachment-extension-points

It is necessary to create a DataSerrvicesAttachment which you e.g. can persist by using the AttachmentPersister. The DataServicesAttachment needs the following instances which you can initialize using the builders or use the AttachmentService:

  • AttachmentHeader
  • AttachmentReference
  • DataServicesThumbnail

I’m afraid that @katerina-blazing-ember meant inline attachment, which is not handled by Data Services. It is just content of field. Maybe Kernel has some tooling for this.
AttachmentService, AttachmentLoader and AttachmentPersister are used for external attachments which are not embedded to the document but assigned to it. It is stored externally then.

Hi @rainer-brave-cloud, I’m afraid, this is not possible in a standard existing way. From kernel point of view, you would need a field in the document model with a certain configuration (see below) and then you could add the content of an attachment to the corresponding field instance in a corresponding document through com.mgmtp.a12.kernel.md.document.api.IDocument#addEntityInstance where the entity instance to add is a IFieldInstance with the content of the attachment as value. The configuration is ‘noValueValidation’ (boolean) for string fields and with this configuration, kernel does not cache the value while validating and also does not validate the value. Unfortunately, this configuration is not available in the SME.