/
app.js
57 lines (51 loc) · 1.3 KB
/
app.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
var express = require('express');
var app = express();
var db = [];
var template = {
"$result": {
"head": {
"actions": {
"$pull": {
"type": "$media.camera",
"success": {
"type": "$network.upload",
"options": {
"storage": {
"type": "s3",
"bucket": "fm.ethan.jason",
"path": "",
"sign_url": "https://imagejason.herokuapp.com/sign_url"
}
}
}
}
}
},
"body": {
"sections": [{
"items": [{
"type": "label",
"text": "Pull me",
"style": {
"padding": "20",
"align": "center"
}
}]
}]
}
}
};
app.get('/sign_url', function (req, res) {
var sig = require('amazon-s3-url-signer');
console.log("params = ", req.body);
/*
var bucket1 = sig.urlSigner('my key', 'my secret');
var url1 = bucket1.getUrl('GET', 'somefile.png', 'mybucket', 10); //url expires in 10 minutes
var url2 = bucket2.getUrl('PUT', '/somedir/somefile.png', 'mybucketonotheraccount', 10); //url expires in 100 minutes
*/
res.json({"$result": "success"});
});
app.get('/', function (req, res) {
res.json(template);
});
app.listen(process.env.PORT || 3000);