DbSqlSession dbSqlSession = commandContext.getDbSqlSession();
dbSqlSession.insert(attachment);
if (content!=null) {
byte[] bytes = IoUtil.readInputStream(content, attachmentName);
ByteArrayEntity byteArray = new ByteArrayEntity(bytes);
dbSqlSession.insert(byteArray);
attachment.setContentId(byteArray.getId());
}
commandContext.getHistoryManager()
.createAttachmentComment(taskId, processInstanceId, attachmentName, true);