F
F
FastClick2019-05-24 11:46:21
Node.js
FastClick, 2019-05-24 11:46:21

How to change image in node.js by link?

I have a link to the image: https://sun1-17.userapi.com/c855128/v855128790/41b... . How can I change the image in the file folder called ava.jpg to the image given in the link?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2019-05-24
@FastClick

const fs = require('fs');
const {request} = require('https');

request('https://sun1-17.userapi.com/c855128/v855128790/41b1f/gNXADknpXlk.jpg', res => {
  res.on('error', console.error).pipe(fs.createWriteStream('/path/to/file/for/save.jpg'));
}).on('error', console.error).end();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question