Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting binary content in Node.js using request

People also ask

Is binary data allowed in GET method?

When a GET method returns binary data, the Swagger document that is generated by IBM® Cúram Social Program Management specifies the Response Content type as anything other than application/json. This response indicates that binary content and not JSON content is provided in the response.

How do you convert node js to binary?

Try this . var fs = require("fs"); fs. readFile('image. jpg', function(err, data) { if (err) throw err; // Encode to base64 var encodedImage = new Buffer(data, 'binary').

What is get request in node js?

GET requests are used to send only limited amount of data because data is sent into header while POST requests are used to send large amount of data because data is sent in the body. Express. js facilitates you to handle GET and POST requests using the instance of express.


OK, after a lot of digging, I found out that requestSettings should have:

encoding: null

And then body will be of type Buffer, instead of the default, which is string.