Advertisement
Guest User

Untitled

a guest
Nov 5th, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* POST an assassin (from the homepage) */
  2. router.post('/assassin', upload.array('file', 10), function(req, res, next) {
  3.   var newAssassin = new Assassin(req.body);
  4.   var newPicture = new Picture();
  5.   newPicture.location = req.files[0].filename;
  6.   newPicture.mimeType = req.files[0].mimetype;
  7.   newPicture.save();
  8.   easyimg.exec("convert ./public/images/uploads/" + newPicture.location + " -resize '275x275^' -gravity center -crop 275x275+0+0 -colorspace Gray -gamma 2.2 +repage ./public/images/uploads/" + newPicture.location).then(
  9.     function(image) {
  10.         console.log("Photo Saved...");
  11.         newAssassin.images.push(newPicture);
  12.         console.log(newAssassin);
  13.         newAssassin.save(function(err, assassin){
  14.           console.log("Before error");
  15.           if(err){ return next(err); }
  16.           console.log("Sending confirmation...");
  17.           sendConfirmation(newAssassin._id);
  18.           console.log("Confirmation sent.");
  19.           res.json(assassin);
  20.         });
  21.     },
  22.     function (err) {
  23.       console.log(err);
  24.     }
  25.   );
  26.  
  27. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement