从流星应用程序内的目录中读取文件 [英] Reading files from a directory inside a meteor app

查看:72
本文介绍了从流星应用程序内的目录中读取文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在/server路径中的流星应用程序中读取公共目录.

How can i read the public directory in a meteor application inside my /server path.

我尝试使用本机'fs'程序包,但我不断遇到找不到文件/目录的错误.

I tried using the native 'fs' package but i keep getting a file/directory not found error.

var fs = Npm.require('fs');
var files = fs.readdirSync('/public/soundfiles/');

有人使用文件系统包读取流星应用程序中的静态文件吗?

Has anyone used the filesystem package to read static files inside a meteor application?

推荐答案

访问不带"/public"部分的文件.在正在运行的Meteor应用程序中,public目录成为您的根目录,位于/public/whatever的所有内容都可以在/whatever处访问.

Access files without the "/public" part. In a running Meteor app, the public directory becomes your root, and everything that is located at /public/whatever can be accessed at /whatever.

此外,如果您正在处理文件,则可能会发现这些有用:

Additionally, if you're playing around with files, you might find these useful:

  • FileSaver.js
  • CollectionFS

这篇关于从流星应用程序内的目录中读取文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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