Skip to content
This repository was archived by the owner on Dec 8, 2022. It is now read-only.

Commit 8441439

Browse files
authored
Merge pull request #152 from hackuci/AwsFix
"Comment out AWS Issues"
2 parents f1dae8f + 6bca7cc commit 8441439

File tree

4 files changed

+2030
-1760
lines changed

4 files changed

+2030
-1760
lines changed

app/.DS_Store

0 Bytes
Binary file not shown.

app/server/routes/api.js

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -544,73 +544,73 @@ module.exports = function(router) {
544544
});
545545

546546
// multer S3 object to upload resumes
547-
var upload = multer({
548-
storage: multerS3({
549-
s3: s3,
550-
bucket: s3BucketName,
551-
key: function (req, file, cb) {
552-
var authToken = req.headers['x-access-token'];
553-
jwt.verify(authToken, JWT_SECRET, (err, id) => {
554-
cb(err, id + '.pdf');
555-
});
556-
},
557-
limits: {
558-
fileSize: 512 * 1024, // max upload size is 512kb
559-
}
560-
})
561-
});
547+
// var upload = multer({
548+
// storage: multerS3({
549+
// s3: s3,
550+
// bucket: s3BucketName,
551+
// key: function (req, file, cb) {
552+
// var authToken = req.headers['x-access-token'];
553+
// jwt.verify(authToken, JWT_SECRET, (err, id) => {
554+
// cb(err, id + '.pdf');
555+
// });
556+
// },
557+
// limits: {
558+
// fileSize: 512 * 1024, // max upload size is 512kb
559+
// }
560+
// })
561+
// });
562562

563563
// upload the resume to AWS S3 using the multer object defined above
564-
router.post('/resume/upload', upload.single('file'), (req, res) => {
565-
res.send(200);
566-
});
567-
568-
// get the resume of a given user
569-
router.get('/resume/:id', isOwnerOrAdmin, (req, res) => {
570-
// check to see if you can access this shiz and
571-
// check if the file exists in s3 anddd
572-
// take the id and put it in a jwt with 30 seconds of validity
573-
574-
var id = req.params.id;
575-
var fileName = id + '.pdf';
576-
577-
var s3Params = {
578-
Bucket: s3BucketName,
579-
Key: fileName
580-
};
581-
582-
s3.headObject(s3Params, (err, data) => {
583-
if (err) {
584-
res.sendStatus(404);
585-
} else {
586-
var token = jwt.sign({fileName: fileName}, JWT_SECRET, {expiresIn: '30s'});
587-
res.json({
588-
token: token
589-
});
590-
}
591-
});
592-
});
593-
594-
router.get('/resume/view/:token', (req, res) => {
595-
// get a token returned by the above object
596-
// extract the filename then return the file
597-
598-
var token = req.params.token
599-
jwt.verify(token, JWT_SECRET, (err, data) => {
600-
601-
if (err) {
602-
res.sendStatus(401)
603-
} else {
604-
var s3Params = {
605-
Bucket: s3BucketName,
606-
Key: data.fileName
607-
};
608-
609-
res.setHeader('Content-type', 'application/pdf');
610-
s3.getObject(s3Params).createReadStream().pipe(res);
611-
}
612-
})
613-
});
564+
// router.post('/resume/upload', upload.single('file'), (req, res) => {
565+
// res.send(200);
566+
// });
567+
568+
// // get the resume of a given user
569+
// router.get('/resume/:id', isOwnerOrAdmin, (req, res) => {
570+
// // check to see if you can access this shiz and
571+
// // check if the file exists in s3 anddd
572+
// // take the id and put it in a jwt with 30 seconds of validity
573+
574+
// var id = req.params.id;
575+
// var fileName = id + '.pdf';
576+
577+
// var s3Params = {
578+
// Bucket: s3BucketName,
579+
// Key: fileName
580+
// };
581+
582+
// s3.headObject(s3Params, (err, data) => {
583+
// if (err) {
584+
// res.sendStatus(404);
585+
// } else {
586+
// var token = jwt.sign({fileName: fileName}, JWT_SECRET, {expiresIn: '30s'});
587+
// res.json({
588+
// token: token
589+
// });
590+
// }
591+
// });
592+
// });
593+
594+
// router.get('/resume/view/:token', (req, res) => {
595+
// // get a token returned by the above object
596+
// // extract the filename then return the file
597+
598+
// var token = req.params.token
599+
// jwt.verify(token, JWT_SECRET, (err, data) => {
600+
601+
// if (err) {
602+
// res.sendStatus(401)
603+
// } else {
604+
// var s3Params = {
605+
// Bucket: s3BucketName,
606+
// Key: data.fileName
607+
// };
608+
609+
// res.setHeader('Content-type', 'application/pdf');
610+
// s3.getObject(s3Params).createReadStream().pipe(res);
611+
// }
612+
// })
613+
// });
614614

615615
/* [ADMIN ONLY]
616616
* {

0 commit comments

Comments
 (0)