A
A
artmirarmi2018-06-25 09:10:02
Node.js
artmirarmi, 2018-06-25 09:10:02

How to copy a file from a remote server in node.js and save it on your server?

I'm just starting to learn technology like node.js. Help me figure out my issue.
How to copy a file from a remote server in node.js and save it on your server?
In PHP, you can do it through the copy () function, but how in node.js?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Perov, 2018-06-26
@sqrdeer

const http = require('http');
const fs = require('fs');

let file = fs.createWriteStream("test.jpg");
let request = http.get("http://test/test.jpg",  response => {
  response.pipe(file);
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question