Skip to content

Commit 4d43a79

Browse files
authored
Merge pull request #1 from greenoco/main
feat: ability to specify ACL for files created on the S3 bucket
2 parents bad10c1 + 4ec7f25 commit 4d43a79

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
22
package-lock.json
3+
/.idea/

lambda.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ const s3 = new AWS.S3();
33
const ylt = require('yellowlabtools');
44

55
// noinspection JSUnusedLocalSymbols
6-
async function runner({id, url, options = {}}, context) {
6+
async function runner({id, url, options = {}, acl}, context) {
77
console.log(`Processing run #${id} on ${url}`);
88

99
// AWS S3 bucket and path
1010
const bucket = process.env.RESULT_BUCKET_NAME;
1111
const keyPrefix = `results/${id}`;
1212

1313
// Function that can save any file on S3 (JSON, screenshot,...)
14-
const saveFile = async (path, content) => s3.putObject({Bucket: bucket, Key: `${keyPrefix}/${path}`, Body: content})
14+
const saveFile = async (path, content, contentType = undefined) => s3.putObject({Bucket: bucket, Key: `${keyPrefix}/${path}`, Body: content, ...(!!contentType ? {ContentType: contentType} : {}), ...(!!acl ? {ACL: acl} : {})})
1515
.promise();
1616

1717
// Let's launch ylt
@@ -21,7 +21,7 @@ async function runner({id, url, options = {}}, context) {
2121
console.log(`Run succeeded`);
2222

2323
data.runId = id;
24-
await saveFile('results.json', JSON.stringify(data));
24+
await saveFile('results.json', JSON.stringify(data), 'application/json');
2525

2626
return {
2727
status: 'processed',

0 commit comments

Comments
 (0)