Hello,
Our ACE add-on grubs a file from a remote location via HTTP request and attaches the file to a Jira issue using Jira Cloud REST API (v2). It works fine with text based files, e.g. json, csv. When attaching an image (jpeg, png), operation finishes successfully, file is attached to the issue, but file size is almost twice of the original file size and image is not displayed - broken.
Here is the code, using request npm package:
let getFileOptions = {
method: 'GET',
uri: attachment.fileUrl,
headers: {
'Content-Type': attachment.mimetype
}
};
request(getFileOptions, (err, response, data) => {
if (err) {
<fail>
}
addonParams.http.asUser(userKey).post({
url: <image url>,
headers: { 'X-Atlassian-Token': 'nocheck' },
multipartFormData: {
file: [data, {
filename: attachment.name,
contentType: attachment.mimetype
}]
}
}, function (err, httpResponse, body) {
if (err) {
<fail>
}
<success>
});
}); Any ideas why image files are broken after attached?
Thanks,
Irena