I have code where I can download the file form URL but I need the file to have the same name as per original file name where it was uploaded
const downloadImage = () => {
var http = require("http"),
Stream = require("stream").Transform,
fs = require("fs");
var url = "http://cutt.ly/0JCQfSh";
http
.request(url, function (response) {
var data = new Stream();
response.on("data", function (chunk) {
data.push(chunk);
});
response.on("end", function () {
fs.writeFileSync('image.png', data.read());
});
})
.end();
};
Open the URL Link on the browser and check the file name its Asset0.png. I want to download a file with the same name