如何读取 Meteor 后端的文件?

How to read a file on the Meteor's backend?

出于某种原因,我需要用暴力修改我的mongodb。 预期的数据在一个文件中,我需要通过读出的文件流更新 mongodb 的值。在 node.js' 的帮助下,我生成了这样的代码,

const fs = require('fs');
    fs.open('./f.csv', 'r', (err, fd) => {
        if(!err) {
            fs.readFile('./server/f.csv', 'utf8', (err,data)=>{console.log(data);});

    }
});

但是,现在我很难找到该文件。执行抛出错误:

{ Error: ENOENT: no such file or directory, open './f.csv' errno: -2, code: 'ENOENT', syscall: 'open', path: './f.csv' }

我曾尝试在 Meteor 的 public 文件夹或服务器文件夹中找到该文件,该文件夹也是 Meteor 的后端,但这些努力都是徒劳的。那么如何让代码在Meteor后台找到文件呢?

欢迎提出任何建议。

最简单的解决方案是将文件放入 /private 并使用 Assets 模块访问它: https://docs.meteor.com/api/assets.html

示例:如果您将文件放在 /private/f.csv

const data = Assets.getText('f.csv');
console.log(data)
// ... Do something with that data