-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
29 lines (26 loc) · 763 Bytes
/
index.js
File metadata and controls
29 lines (26 loc) · 763 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
/*
* Image resizer
*
* @author Sheeban
* @created 01/09/2016
*/
"use strict";
let ImageResizeProcessor = require('./processor/ImageResizeProcessor');
let resizeProcessor = new ImageResizeProcessor();
exports.handler = (event, context, callback) => {
// Get the object from the event and show its content type
const bucket = event.Records[0].s3.bucket.name;
const key = decodeURIComponent(event.Records[0].s3.object.key.replace(/\+/g, ' '));
const params = {
Bucket: bucket,
Key: key
};
resizeProcessor.exec(params)
.then((response) => {
console.log("Successfully resized images.");
context.succeed();
}).catch((error) => {
console.log("Error : ", error);
context.fail();
});
};