Simon
Simon

Reputation: 310

From NodeJS Buffer to S3 file

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:

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.

Upvotes: 1

Views: 979

Answers (1)

Simon
Simon

Reputation: 310

It turns out that my method for dividing the data stream was leaving a trailing /r/n on the end of each file, PDFs don't seem to mind, everything else does.

Upvotes: 1

Related Questions