1
votes

I have a zip file represented in string which is a response of a POST request. I want to write zip file from that string. Do i need to convert that string into some other format to retrieve the zip file or is there any module for it. NODE JS.

response:

--MIMEBoundaryurn_uuid_C91296EA5FF69EE9571479794474627561290 Content-Type: application/zip Content-Transfer-Encoding: binary Content-ID:

-----data -----

--MIMEBoundaryurn_uuid_C91296EA5FF69EE9571479794474627561190--

1

1 Answers

0
votes

Note: This answer was written before information that the file is MIME-encoded was added to the answer.

If what you have in your variable is a ZIP file already then you don't need to convert it before saving. You can write files in Node with:

fs.writeFile('filename.zip', data, (err) => {
  console.log(err ? 'Error: '+err : 'File saved');
});

Where data contains your data to be saved.

Update

It would be easier to answer your questions if you included all of the relevant info at the beginning instead of adding it after answers are already posted.

If it's an eBay report from the API then search for eBay API on npm.

If it's a MIME-encoded file then search Stack Overflow for MIME-decoding.

There are a lot of questions and answers posted on this subject already.

For more info see: https://en.wikipedia.org/wiki/MIME