node.js - Meteor CSV file upload -


i new meteor making app upload large csv file, when run app files uploaded home directory (ubuntu)and mongodb collection can see robomongo ,after receiving error on console (stderr) error: enoent, open '/imports/tdcdata.csv' have changed ./ ,~/ , home/user/imports not work. contribution in advance; here code :

meteor.methods({    'uploadfile': function(fileid, filename) {      var fs = meteor.npmrequire('fs');      var file = uploads.find({        _id: fileid      });      meteor.settimeout(function() {        var filepath = '~/imports/' + filename;        //var filepath = '/imports/uploads-' + fileid + '-' + filename;        csv().from.stream(            fs.createreadstream(filepath), {              'escape': '\\'            })          .on('record', meteor.bindenvironment(function(row, index) {            album.insert({              'account number': row[0],              'album title': row[1],              'track artist': row[2],              'track title': row[3],              'isrc': row[4],              'source upc': row[5],            })          }, function(error) {            console.log(error);          }))          .on('error', function(err) {            console.log(err);          })          .on('end', function(count) {            })      }, 1000)    }  })

you can use fs.debug = true information path.

fs.debug = true  upload = new fs.collection("uploads", {   stores: [new fs.store.filesystem("uploads")] }); 

the path var filepath = process.env.pwd + "/.meteor/local/cfs/files/uploads/uploads-" + fileid + "-" + filename;

i think there way write this, think works.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -