How to use "fs" in Meteor?

How to use “fs” in Meteor?
How to declare?
Ex:

var fs = Npm.require('fs');
var path = Npm.require('path');
var basePath = path.resolve('.').split('.meteor')[0];

Meteor.methods({
    witeFile: function () {
        console.log(basePath);
        var temPath = basePath + 'cpanel/sever/gen';
        console.log(temPath);
        fs.writeFileSync(temPath + 'message.js', 'Hello Node.js', 'utf8');
    }
});

But don’t work.
Please help me.

1 Like

hey,

i just tested that code:

var fs = Npm.require('fs');
console.log(fs)

this works fine for me on the server

3 Likes

How about on the client? (Need to read camera roll on iOS)

Thanks, now work fine for me.

you cant use nodejs code on the client
for that you need cordova plugins like:
https://github.com/driftyco/cordova-camera-roll

Can I do it using Javascript? I saw some file reading functionality (Reader, etc) The security of this seems complex though.

I think I’ll open a new thread on this.