I'm trying to write codes with javascripts to upload a file version with the endpoint:
It works well if I pass the File object in the formData for the file parameter.
let body = "";
const binary = this.ab2str(_fileBuffer);
body +=
"--" +
boundary +
'\r\nContent-Disposition: form-data; name="attributes"' +
"\r\n\r\n" +
`{"name": "${item.filename}"}` +
"\r\n" +
"--" +
boundary +
'\r\nContent-Disposition: form-data; name="file"; filename="' +
item.filename +
'"' +
"\r\nContent-type: application/octet-stream" +
"\r\n\r\n" +
binary +
"\r\n" +
"--" +
boundary +
"--\r\n";
try {
const response = await axios.post(
`${getUploadFileVersion(identifier)}`,
body,
headers: {
"Content-Type": `multipart/form-data; boundary=${boundary}`,
Authorization: `Bearer ${tokenInfo.accessToken}`