-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
33 lines (29 loc) · 912 Bytes
/
index.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
const path = require("path");
const uploadToS3 = require("./uploadToS3");
const run = async (job, settings, action, type) => {
if (type != "postrender") {
throw new Error(
`[nexrender-action-upload-s3-presigned] action can be only run in postrender mode, you provided: ${type}.`
);
}
const {logger} = settings;
const {
input,
params: { url, contentType },
} = action;
try {
let finalInput = input ?? job.output;
if (!path.isAbsolute(finalInput))
finalInput = path.join(job.workpath, finalInput);
logger.log(
`[nexrender-action-upload-s3-presigned] uploading to presigned-url: ${url}`
);
await uploadToS3(url, finalInput, contentType, logger);
} catch (error) {
logger.log(
`[nexrender-action-upload-s3-presigned] failed uploading to presigned-url: ${url} \n ${error?.message}`
);
throw error;
}
};
module.exports = run;