forked from fippo/rtcstats-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstore.js
More file actions
31 lines (27 loc) · 730 Bytes
/
store.js
File metadata and controls
31 lines (27 loc) · 730 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
const AWS = require('aws-sdk');
const zlib = require('zlib');
module.exports = function(config) {
AWS.config = config.s3;
const s3bucket = new AWS.S3({
params: {
Bucket: config.s3.bucket
}
});
return {
put: function(key, data) {
zlib.gzip(data, (err, data) => {
if (err) {
console.log("Error gzipping data: ", err);
} else {
s3bucket.upload({ Key: key + '.gz', Body: data }, (err, data) => {
if (err) {
console.log("Error uploading data: ", err);
} else {
console.log("Successfully uploaded data to bucket: %s, key: %s", config.s3.bucket, key);
}
});
}
})
},
};
}