查找项目目录的绝对基本路径 [英] Find absolute base path of the project directory

查看:80
本文介绍了查找项目目录的绝对基本路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

直到现在,我们可以使用以下代码片段获取文件的绝对路径,以便稍后作为readStream打开:

Until now we could get the absolute path of a file to open later as readStream with this code snippet:

var base = path.resolve('.');
var file = base + '/data/test.csv';

fs.createReadStream(file)

自流星0.6.5开始,基本路径指向.meteor/local/build/programs/...

Since Meteor 0.6.5 the base path is pointing to .meteor/local/build/programs/...

还有Assets API,该API只能返回已读文档,但不能返回路径.我们但是需要一个流来处理一些更大的数据文件吗?

There is also the Assets API, which but can not give us back a path but only the read document. We but need a stream to process some bigger data files?

推荐答案

从1.3版开始, Assets.absoluteFilePath(assetPath)

似乎是可靠获取项目路径的最佳方法.

seems to be the best way to get the project path reliably.

流星GitHub

这篇关于查找项目目录的绝对基本路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆