瀏覽代碼

file upload try catch

Ivan Greenking 11 月之前
父節點
當前提交
1edd8fc2e1
共有 1 個文件被更改,包括 6 次插入1 次删除
  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 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 {
             res.status(503).send('permission denied')