Hiya all thanks in advance for any help you can provide. I am using C9.io, node, express, multer, gridfs-stream. And Im getting:
/home/ubuntu/workspace/node_modules/multer/index.js:25
mkdirp(dest, function(err) { if (err) throw err; });
Error: EACCES, mkdir '/uploads'
I run the server.js script and that is the error that I get. I believe is something to do with permissions but i have tried chown the public folder and chmod ax, you guys have any other suggestions as to what to do?. Still get same error. The code I have is server.js
app.use('/uploads', express.static(__dirname + '/public/uploads'));
app.use(multer({dest: '/uploads/'}));
app.use(methodOverride());
app.get('/form',function (req,res){
res.render('form');
});
app.get('/api/taxis', function(req,res){
taxiModel.Taxi.find({}).exec(function(error,collection){
res.send(collection);
});
});
// app.get('user/:name', function(req,res){
// taxiModel.Taxi.find({name:req.param.nmae},function(err,docs){
// if(err)res.json(err);
// else res.render();
// }
// });
app.get('*', function (req,res){
res.render('index');
});
app.post('/new',function(req,res){
var dirname = require('path').dirname(__dirname);
var filename = req.files.dnimgfront.name;
var path = req.files.dnimgfront.path;
var type = req.files.dnimgfront.mimetype;
var gfs = Grid(conn.db);
var read_stream = fs.createReadStream(dirname + '/' + path);
var writestream = gfs.createWriteStream({filename: filename});
read_stream.pipe(writestream);
});
mongoose.connect('mongodb://jsrosas:12345@ds031721.mongolab.com:31721/taxis');
var conn=mongoose.connection;
conn.once('open', function(){
console.log('connected to mongodb succesfully!');
});
app.listen(process.env.PORT, process.env.IP);