I have a binary data(like image file) in Buffer object(not file), and want to serve the raw binary data to client through http.ServerResponse.
How can I do it ?
Node.js – Send a binary Buffer to client through http.ServerResponse in Node.js
binaryexpressnode.js
Related Topic
- Node.js + Nginx – What now
- Javascript – How to decide when to use Node.js
- Node.js – How to exit in Node.js
- Javascript – In Node.js, how to “include” functions from the other files
- Node.js – Using Node.js as a simple web server
- Node.js – How to do Base64 encoding in Node.js
- Javascript – Using Node.JS, how to read a JSON file into (server) memory
- Question regarding Lucene scoring
Best Answer
I managed to find out the answer. Just add "binary" encoding to both write() and end().
Note that both "write" and "end" function requires the 'binary' encoding specified. Otherwise, the buffer is encoded as UTF-8. (So, JPEG header "ff d8 ff e0" will be "c3 bf c3 98 c3 bf c3 a0"...)