-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (30 loc) · 920 Bytes
/
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
35
36
37
38
'use strict';
import fs from 'fs';
import config from 'config';
import URL2PNG from './lib/url-png.js';
import CloudStorage from './lib/cloud-storage.js';
console.log(`Configuration: ${JSON.stringify(config)}`);
function main() {
const url = 'www.cloudanix.com';
const url2png = new URL2PNG(config);
const cloudStorage = new CloudStorage(config.storage.auth);
url2png.generateScreenshot(url)
.then(result => {
console.log(`url2png success: ${result}`);
return cloudStorage.uploadFile(result, config.storage.options);
})
.then(filePath => {
console.log(`upload file success: ${filePath}`);
fs.unlink(filePath, (error) => {
if (error) {
console.log(error);
} else {
console.log(`file deleted: ${filePath}`);
}
});
})
.catch(error => {
console.log(`failed to generate screenshot from url2png and upload to google storage for ${url} : ${error}`);
});
}
main();