I have an api which returns Binary Media Data (The data contains an image), I want to send this data to a file. I am able to do this via CURL command using -o. But I am not able to do the same in node js. Please help.
-
You may like to use npmjs.com/package/request moduleArif Khan– Arif Khan2018-05-10 07:15:27 +00:00Commented May 10, 2018 at 7:15
-
using pipe method? By "send" here I mean storing data in a file.Amir Saleem– Amir Saleem2018-05-10 07:18:23 +00:00Commented May 10, 2018 at 7:18
Add a comment
|
1 Answer
You may use request module something like following
const fs = require('fs');
const request = require('request');
request
.get('http://example.com/image.png')
.pipe(fs.createWriteStream('image.png'))
1 Comment
Arif Khan
Great, If any answer works, You should accept that answer this will help to other as well