Skip to content

Commit 479b25f

Browse files
committed
pic works
1 parent 055b53c commit 479b25f

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

lab-allie/.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ APP_SECRET='top secret keyes'
22
PORT=3000
33
MONGODB_URI='mongodb://localhost/cfgram-dev'
44
AWS_BUCKET='lab-18-allie'
5-
AWS_ACCESS_KEY_ID='AKIAJ77JRTCF4NFJROKQ'
6-
AWS_SECRET_ACCESS_KEY='6XeUxTYNq2xgYi9uB9LarhM9wFg1wW44fs3QrGlbx'
5+
AWS_ACCESS_KEY_ID='AKIAIBKD3KMKCI2UVQKQ'
6+
AWS_SECRET_ACCESS_KEY='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'

lab-allie/controller/pic-controller.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const s3 = new AWS.S3();
2424
function s3UploadProm(params) {
2525
return new Promise((resolve, reject) => {
2626
s3.upload(params, (err, data) => {
27+
console.log(err);
2728
resolve(data);
2829
});
2930
});
@@ -43,19 +44,22 @@ exports.uploadPic = function(req) {
4344
Key: `${req.file.filename}${ext}`,
4445
Body: fs.createReadStream(req.file.path),
4546
};
46-
4747
return Gallery.findById(req.params.id)
4848
.then(() => s3UploadProm(params))
4949
.then(s3Data => {
50+
console.log('s3Data', s3Data);
51+
5052
del([`${dataDir}/*`]);
5153
let picData = {
5254
name: req.body.name,
53-
desc: req.body.desc,
55+
description: req.body.description,
5456
userID: req.user._id,
5557
galleryID: req.params.id,
5658
imageURI: s3Data.Location,
5759
objectKey: s3Data.Key,
5860
};
5961
return new Pic(picData).save();
60-
});
62+
})
63+
.then(pic => pic)
64+
.catch(err => Promise.reject(err));
6165
};

lab-allie/routes/pic-routes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = function(router) {
1212
debug('#POST /pic/:id');
1313
picCtrl.uploadPic(req)
1414
.then(pic => res.json(pic))
15-
.catch(err => res.send(err));
15+
.catch(err => res.send(err)); ///res.status, res.send
1616
});
1717

1818
router.get('/pic/:id', bearerAuth, (req, res) => {

0 commit comments

Comments
 (0)