I attached a file with a task and fetched its content using
runtime/tasks/{taskId}/attachment/{attachmentId}/contentapi. I am able to save content of text file successfully but for other formats data is not getting saved properly and saved files are getting corrupted.