Fixed S3 document upload to have minimally functional model
This commit is contained in:
15
s3upload.js
15
s3upload.js
@@ -13,12 +13,13 @@ const S3_BUCKET = process.env.bucket;
|
||||
exports.sign_s3 = (req, res) => {
|
||||
console.log("Hitting bucket: " + S3_BUCKET);
|
||||
const s3 = new aws.S3(); // Create a new instance of S3
|
||||
if (!req.body.fileName || req.body.fileType) {
|
||||
res.json({ success: false, error: "fileName or fileType missing." });
|
||||
console.log("Error: fileName or fileType missing. ");
|
||||
return;
|
||||
}
|
||||
|
||||
// if (!req.body.fileName || req.body.fileType) {
|
||||
// console.log('req.body.fileName', req.body.fileName)
|
||||
// console.log('req.body.fileType', req.body.fileType)
|
||||
// res.json({ success: false, error: "fileName or fileType missing." });
|
||||
// console.log("Error: fileName or fileType missing. ");
|
||||
// return;
|
||||
// }
|
||||
const fileName = req.body.fileName;
|
||||
const fileType = req.body.fileType;
|
||||
// Set up the payload of what we are sending to the S3 api
|
||||
@@ -36,7 +37,7 @@ 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}`
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user