0
var conn = mongoose.createConnection(config.db);

conn.once('open', function (err) {

    if (err) {
        next(err);
        return;
    }
    var source = fs.createReadStream(req.files.sample.path);
    var gfs = Grid(conn.db, mongoose.mongo);
    var id = mongoose.Types.ObjectId();
    var target = gfs.createWriteStream({
        _id: id,
        filename: req.files.sample.name
    });

    source.pipe(target).on('close', function () {
        project.documentation = id;
        persistProject(req, res, next, project);
    });
}

When I'm trying to upload it os showing the below error. Terminating application: undefined

events.js:72 throw er; // Unhandled 'error' event ^ Error: ENOENT, open 'null/60c0f337f3413edbc5eb3bb27fa3269f'

Why this error is coming? Please help me to solve it.

kinakuta
  • 8,819
  • 1
  • 34
  • 48
gayatri
  • 3
  • 2

1 Answers1

0

ENOENT: Error, No Entry. Or to make it more precise: req.files.sample.path seems not to be the correct path. The error says 'null/...' - so maybe req.files.sample.path is empty?

If I would dig further, I would ask myself: Where do you "upload" to and what are the default paths there? Is that mongoDB working correctly on command line?

CFrei
  • 3,149
  • 1
  • 12
  • 25
  • Check if that req.files.sample.path is set correctly. For example '/' is different to './', specially if you upload your stuff to another environment. – CFrei Sep 23 '14 at 07:23