Parcourir la source

file upload try catch

Ivan Greenking il y a 11 mois
Parent
commit
1edd8fc2e1
1 fichiers modifiés avec 6 ajouts et 1 suppressions
  1. 6 1
      index.js

+ 6 - 1
index.js

@@ -137,7 +137,12 @@ const upload  = require('multer')({ dest: uploadPath })
 
 
             let {models: {Image }} = await getModels(decoded.sub)
             let {models: {Image }} = await getModels(decoded.sub)
             let image = await Image.fromFileData(req.file)
             let image = await Image.fromFileData(req.file)
-            res.end(JSON.stringify({_id: image._id, url: image.url}))
+		if (image){
+			res.end(JSON.stringify({_id: image._id, url: image.url}))
+		}
+		else {
+			res.end('YAKAS CHUHNYA')
+		}
         }
         }
         else {
         else {
             res.status(503).send('permission denied')
             res.status(503).send('permission denied')