-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathObjectUtils.js
executable file
·57 lines (53 loc) · 1.49 KB
/
ObjectUtils.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// pRoy24 tokenplex
module.exports = {
isNonEmptyObject: function(obj) {
if (typeof(obj) === "undefined" || obj === null || Object.keys(obj).length === 0) {
return false;
}
return true;
},
isNonEmptyArray: function(arr) {
if (typeof arr === "undefined" || arr === null || arr.length === 0) {
return false;
}
return true;
},
isEmptyString: function(str) {
if (typeof str === "undefined" || str === null || str.length === 0) {
return true;
}
return false;
},
isNonEmptyString: function(str) {
if (typeof str === "undefined" || str === null || str.length === 0) {
return false;
}
return true;
},
writeFileToS3Location: function(coinSymbol, coinName) {
var AWS = require('aws-sdk'),
fs = require('fs');
const coinURI = 'public/images/charts/' + coinName + '.png';
// For dev purposes only
// Add AWS Config
// Read in the file, convert it to base64, store to S3
fs.readFile(coinURI, function (err, data) {
if (err) {
// Silently absorb write error for now
// TODO handle upload to S3 error
console.log(err);
}
const base64data = new Buffer(data, 'binary');
const s3 = new AWS.S3();
s3.upload({
Bucket: 'images.tokenplex.io',
Key: coinSymbol+".png",
Body: base64data,
ACL: 'public-read'
},function (resp) {
console.log(arguments);
console.log('Successfully uploaded package.');
});
});
}
}