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.
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').
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With