Skip to content

Instantly share code, notes, and snippets.

@Jerga99
Created July 15, 2018 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jerga99/ce8972abfe1a0408e376df20d88f87ec to your computer and use it in GitHub Desktop.
Save Jerga99/ce8972abfe1a0408e376df20d88f87ec to your computer and use it in GitHub Desktop.
const express = require("express");
const router = express.Router();
const upload = require('../services/multer');
const singleUpload = upload.single('image')
router.post('/image-upload', function(req, res) {
singleUpload(req, res, function(err, some) {
if (err) {
return res.status(422).send({errors: [{title: 'Image Upload Error', detail: err.message}] });
}
return res.json({'imageUrl': req.file.location});
});
})
module.exports = router;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment