0

How to save and write data acquired by request or fetch as executable?
For example I use

require('request').get('https://github.com/harujisaku/mini-player/raw/master/mini-player.exe', async (e, r, b) => {
    require('fs').writeFileSync(path+'test.exe', b);
});

But instead of working .exe file I get a broken file. How to save and write file from server data (from github as example) correctly, so .exe file would not break?

Soundar
  • 3
  • 1

1 Answers1

0

This might help you, credits to 'Michelle Tilley' from : https://stackoverflow.com/a/11944984/5203821

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

const file = fs.createWriteStream("mini-player.exe");
const request = http.get("https://github.com/harujisaku/mini-player/raw/master/mini-player.exe", function(response) {
  response.pipe(file);
});