You can use addAttachment()
with a DataSource
or an InputStreamSource
. Both interfaces offer Byte array implementations (e.g. ByteArrayDataSource
or ByteArrayResource
).
helper.addAttachment("doc", new ByteArrayResource(doc));
You also might reconsider polluting your memory with that byte array. Your DAO might support streams and so does addAttachment()
.