Multer, Node, EACCES error on C9.io

自古美人都是妖i 提交于 2019-12-06 21:44:33

Did you ever figure this out? I was getting the EAccess error as well.

To fix the issue I did the following.

I had to make sure that path = require('path') was included also not sure how old your question is compared to Multer releases but i looks like in version 1.0.3 you have to multer = require('multer') then below that upload = multer() also this is where you stick in the config information.

You end up with

var multer = require('multer'),
/*some config stuff for multer*/
    Limits = { fileSize: 10 * 1024 * 1024, files:1 };

/* specify one file so ppl can't flood the server with infinite file
  uploads or make it what you want but don't just leave it. Alternately 
  you can write the config stuff like the dest: value below. */

/*pass multer the configuration information and/or set config information*/
var upload = multer({dest: path.join(__dirname+'/uploads'),
                     limits: Limits
                    });

then do app.post like

app.post('/uploads', upload, function(req,res){
    // expose req.file to a variable or do some process by which you send it to your database.  
})

hope this helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!