Answer the question
In order to leave comments, you need to log in
How to get file content from node.js link?
There is a file, here is a link to it: test.ru/text.txt (example), how can I get the contents of this file through node.js. The file contains a number.
Answer the question
In order to leave comments, you need to log in
I googled for you.
If the file is large, then take writeSteam
const http = require('http');
const fs = require('fs');
const file = fs.createWriteStream("file.jpg");
const request = http.get("http://test.ru/text.txt ", function(response) {
response.pipe(file);
});
const http = require('http');
var downFile = "";
const request = http.get("http://test.ru/text.txt ", function(response) {
downFile(response);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question