• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

308
Views
Zip file as a buffer in javascript

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?

almost 3 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error