This repository was archived by the owner on Dec 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
46 lines (35 loc) · 1.15 KB
/
Copy pathapp.js
File metadata and controls
46 lines (35 loc) · 1.15 KB
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
'use strict';
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
app.use(express.static(__dirname+'/'));
app.use(bodyParser.json()); // for parsing application/json
const port = process.env.PORT || 3000;
function baseName(str){
var base = new String(str).substring(str.lastIndexOf('/') + 1);
if(base.lastIndexOf(".") != -1)
base = base.substring(0, base.lastIndexOf("."));
return base;
}
app.post('/', (req, res) => {
console.log(req.body);
console.log('=============================');
var bucketName = req.body.Records[0].s3.bucket.name;
console.log('==== bucket information =====');
console.log(bucketName);
console.log('=============================');
var uplodedFile = req.body.Records[0].s3.object.key;
console.log('==== uploaded file ====');
console.log(uplodedFile);
var filename = baseName(uplodedFile);
console.log(filename);
console.log('=============================');
res.send("");
});
var server = app.listen(port, () =>{
console.log(`listening on *:${port}`);
});
process.on('SIGINT', () => {
console.info("Interrupted")
process.exit(0)
})