-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlambdaCode.js
More file actions
32 lines (21 loc) · 958 Bytes
/
lambdaCode.js
File metadata and controls
32 lines (21 loc) · 958 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
32
'use strict';
let AWS = require('aws-sdk'); // lets you perform systematic actions on other services such as S3
let s3 = new AWS.S3();
exports.handler = async (event) => {
console.log('Event S3 Object: ', event.Records[0].s3.object);
let newImage = event.Records[0].s3.object.key;
console.log('newImage: ', newImage);
// 'download' images.json from the S3 bucket
let manifest = await s3.getObject({ Bucket: 'sjt-image-bucket', Key: 'testfile.json' }).promise();
console.log('MANIFEST ContentLength: ', manifest.ContentLength);
// upload images.json file back to the S3 bucket
// s3.putObject({Bucket: 'sjt-image-bucket', Key: 'images.json'}, Body: manifest})
// await s3.putObject({Bucket: 'sjt-image-bucket', Key: 'images.json', Body: });
// S3.putObject({Bucket: "sjt-image-bucket", Key: "images.json"})
// TODO implement
const response = {
statusCode: 200,
body: JSON.stringify(event),
};
return response;
};