MCPcopy Create free account
hub / github.com/SoftwareEngineeringDaily/software-engineering-daily-api / signS3

Function signS3

server/helpers/s3.js:20–38  ·  view source on GitHub ↗
(S3_BUCKET, fileType, newFileName, cbSuccess, cbError)

Source from the content-addressed store, hash-verified

18}
19
20function signS3(S3_BUCKET, fileType, newFileName, cbSuccess, cbError) {
21 // Probably only need to do this once:
22 const s3 = new aws.S3({
23 accessKeyId: process.env.AWS_ACCESS_KEY_ID,
24 secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
25 });
26
27 const s3Params = getS3Config(S3_BUCKET, fileType, newFileName);
28 s3.getSignedUrl('putObject', s3Params, (err, data) => {
29 if (err) {
30 return cbError(err);
31 }
32 const returnData = {
33 signedRequest: data, // <-- the useful one
34 url: `https://${S3_BUCKET}.s3.amazonaws.com/${newFileName}`
35 };
36 return cbSuccess(returnData);
37 });
38}
39
40export default {
41 signS3

Callers 2

signS3AvatarUploadFunction · 0.90

Calls 3

getS3ConfigFunction · 0.85
cbErrorFunction · 0.50
cbSuccessFunction · 0.50

Tested by

no test coverage detected