Task task = getTaskFromRequest(taskId);
if (request instanceof MultipartHttpServletRequest) {
result = createBinaryAttachment((MultipartHttpServletRequest) request, task, serverRootUrl, response);
} else {
AttachmentRequest attachmentRequest = null;
try {
attachmentRequest = objectMapper.readValue(request.getInputStream(), AttachmentRequest.class);
} catch (Exception e) {
throw new ActivitiIllegalArgumentException("Failed to serialize to a AttachmentRequest instance", e);