Fixed scaling of images. Fixed server.js issues for production

This commit is contained in:
Patrick Fic
2020-01-15 22:24:35 -08:00
parent 1134f26282
commit 2971c72f76
11 changed files with 246 additions and 40 deletions

View File

@@ -37,7 +37,33 @@ exports.sign_s3 = (req, res) => {
res.json({ success: false, error: err });
}
// Data payload of what we are sending back, the url of the signedRequest and a URL where we can access the content after its saved.
const returnData = {
const returnData = {
signedRequest: data,
url: `https://${S3_BUCKET}.s3.amazonaws.com/${fileName}`
};
// Send it all back
res.json({ success: true, data: { returnData } });
});
};
exports.get_s3 = (req, res) => {
const s3 = new aws.S3(); // Create a new instance of S3
const fileName = req.body.fileName;
//const fileType = req.body.fileType;
// Set up the payload of what we are sending to the S3 api
const s3Params = {
Bucket: S3_BUCKET,
Key: fileName,
Expires: 500
};
// Make a request to the S3 API to get a signed URL which we can use to upload our file
s3.getSignedUrl("getObject", s3Params, (err, data) => {
if (err) {
console.log(err);
res.json({ success: false, error: err });
}
// Data payload of what we are sending back, the url of the signedRequest and a URL where we can access the content after its saved.
const returnData = {
signedRequest: data,
url: `https://${S3_BUCKET}.s3.amazonaws.com/${fileName}`
};