DEV Community

Automation125
Automation125

Posted on

How to save octet-stream response content as pdf in node js

I have an api which is returning the pdf content as octet-stream in response body, can some one help me to save it as pdf.i tried to convert the content to base 64 using nodejs buffer and saving encoded content into .pdf file but not working

Top comments (1)

Collapse
 
joelbonetr profile image
JoelBonetR πŸ₯‡ • Edited
  • In Octet-stream you will be receiving the response as "Encoded Binary Data"
  • As you said, your need to convert the response data into "Decoded Base64 String"
  • And finally save it as PDF. You may want to check base64toPdf npm package, either to use it or to check how it handles everything.

You are in the right path, it should be some nuance that stops you from completing this, best wishes! 😁