I have own SharePoint integration in JavaScript.
For sending files I use endpoint:
${SITE}/_api/web/GetFolderByServerRelativeUrl('catalog')/Files/add(url='${fileName}',overwrite=true)
Everything works properly when I uploaded .jpg and .txt files.
But when I try to upload .zip file, the file in SharePoint is not readable (I had Error 79 - Inappropriate file type or format
).
Locally (generated by archiver library) this file is correct.
I sending files to SharePoint as a buffer generated by:
const buffer = fs.readFileSync(exportedAppDataArchive.pathToFile);
I also tried
const buffer = fs.readFileSync(exportedAppDataArchive.pathToFile).buffer;
and my function to send it to the SharePoint looks like:
await axiosInstance.post(fileCollectionEndpoint, arrayBuffer, {
// responseType: 'buffer',
headers: {
// 'Content-Type': 'application/zip',
// 'User-Agent': 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)',
Cookie: cookie,
Authorization: `Bearer ${digest}`,
},
});
In comments it's my tries with different options...
What is the properly way to send a .zip file as a buffer?