-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (28 loc) · 1.05 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"use strict";
const axiosCookieJarSupport = require("axios-cookiejar-support").default;
const axios = require("axios");
const { CookieJar } = require("tough-cookie");
const Nodestream = require("nodestream");
const destination = new Nodestream({
// This tells nodestream which storage system it should interact with
// Under the hood, it will try to require `nodestream-filesystem` module
adapter: "filesystem",
// This object is always specific to your adapter of choice - always check
// the documentation for that adapter for available options
config: {
// The `filesystem` adapter requires a `root` configuration option, so let's provide one
root: [__dirname, ".storage"]
}
});
axiosCookieJarSupport(axios);
const transport = (url, destination) =>
axios
.get(url, {
jar: new CookieJar(),
responseType: "stream",
withCredentials: true
})
.then(response => response.data.pipe(destination))
.catch(error => console.log(error));
const recall = (destination, file) => {}
module.exports = { transport, recall }