(S3_BUCKET, fileType, newFileName, cbSuccess, cbError)
| 18 | } |
| 19 | |
| 20 | function 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 | |
| 40 | export default { |
| 41 | signS3 |
no test coverage detected