We are currently migrating from A12 2023.06ext 11 to 2024.06 ext 9.
Documents for a specific domain model have an attachment that we read into our business logic after the document is created (in a DocumentAfterCreateEvent Listener) for further processing.
Previously, we used a workaround via the AttachmentHandler (#collectAttachmentIDs) to query the attachment ID and load it from the content store (content-storage = DB). Unfortunately, this is no longer possible. Is there a (better) way to get the content of the attached file in A12 2024.06ext9?
Hi @mathias-early-ravine
To get the binary content of an attachment from a document, use ContentStoreService.
For private attachments (the default), you first need to request a download ticket, then use it to retrieve the content:
// 1. Request a time-limited download URL from the attachment ID
// The second parameter is the ticket duration in seconds
String downloadUrl = contentStoreService.requestContentUrl(attachmentId, 100);
// 2. Extract the ticket ID from the URL (format: …/download/{ticketId})
String ticketId = downloadUrl.split("/download/")[1];
// 3. Retrieve the content stream using the ticket ID
ContentStream contentStream = contentStoreService.getContent(ticketId)
Hope it helps.