I have next code, but it throws “Bad request. Status code: 400”. What is wrong with code below (size of file from link 0.1mb, its png image):
const res = await fetch(mediaUrl);
const arrayBuffer = await res.arrayBuffer();
const buffer = Buffer.from(arrayBuffer);
const filename = mediaUrl.split('/').pop();
const contentType =
res.headers.get('content-type') || 'application/octet-stream';
const formData = new FormData();
formData.append('file', buffer, {
filename,
contentType,
});
const response = await fetch(urlForAttach, {
method: 'POST',
headers: {
Authorization: `${authHeader}`,
'X-Atlassian-Token': 'no-check',
Accept: 'application/json',
...formData.getHeaders(),
},
body: formData,
});