Hi all,
I studied the ostrio:files examples and applied to my project to upload a csv file to the server.
Now I’d like to read the csv file content but don’t know where to start? Can someone help me find a solution?
I tried to configure the storagePath to the ‘private’ folder and use Assets.getText(fileObj._id + ‘.csv’) but it threw an exception kind of ‘unknown asset’.
Thanks
Update: I could read the file content now. Here what I tried:
- install the fs-extra package:
meteor npm install --save fs-extra - in the event onAfterUpload, make use of the fs package, e.g.
FileUploads.addListener(‘afterUpload’, function(fileRef) {
fs = Npm.require(‘fs’);
console.log(fs.readFileSync(fileRef.path, ‘utf8’));
});
// Reference:
https://gist.github.com/awatson1978/4625493
https://nodejs.org/api/fs.html