-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathresult_file.js
More file actions
33 lines (26 loc) · 632 Bytes
/
result_file.js
File metadata and controls
33 lines (26 loc) · 632 Bytes
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
import fs from 'fs';
import path from 'path';
export default class ResultFile {
constructor(api, fileInfo) {
this.api = api;
this.fileInfo = fileInfo;
}
get url() {
return this.fileInfo.Url;
}
get fileName() {
return this.fileInfo.FileName;
}
get fileSize() {
return this.fileInfo.FileSize;
}
async save(filePath) {
let downloadPath;
if (fs.existsSync(filePath) && fs.statSync(filePath).isDirectory()) {
downloadPath = filePath + path.sep + this.fileName;
} else {
downloadPath = filePath;
}
return this.api.client.download(this.url, downloadPath);
}
}