cezboil 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +11 -0
- package/random.js +16 -0
package/package.json
ADDED
package/random.js
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
const http = require("http"); // or 'https' for https:// URLs
|
2
|
+
const fs = require("fs");
|
3
|
+
|
4
|
+
const file = fs.createWriteStream("file.jpg");
|
5
|
+
const request = http.get(
|
6
|
+
"http://i3.ytimg.com/vi/J---aiyznGQ/mqdefault.jpg",
|
7
|
+
function (response) {
|
8
|
+
response.pipe(file);
|
9
|
+
|
10
|
+
// after download completed close filestream
|
11
|
+
file.on("finish", () => {
|
12
|
+
file.close();
|
13
|
+
console.log("Download Completed");
|
14
|
+
});
|
15
|
+
}
|
16
|
+
);
|