I have a buffer returned by an API call containing file data however when I try to S3.Upload()
or fs.write()
the file is corrupt for anything except PDFs (png, jpg, .doc, .docx are the key types I need). For PDFs I just use the binary data as it comes in (fs.writeFile('myFile.docx', myBuffer)
) but I've also tried:
fs.writeFile('myFile.docx', myBuffer.toString('base64'))
,fs.writeFile('myFile.docx', myBuffer.toString('utf8'))
,fs.writeFile('myFile.docx', myBuffer.toString('binary'))
I'm sure it's to do with encoding the binary from the buffer but I've reached the limit of my knowledge with the above attempts and am desperate to get this fixed asap!
Thanks
via Simon
No comments:
Post a Comment