Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Meteor从服务器下载二进制文件?_Meteor - Fatal编程技术网

Meteor从服务器下载二进制文件?

Meteor从服务器下载二进制文件?,meteor,Meteor,使用Meteor和Iron路由器,是否有Meteor模块可以方便地在Meteor应用程序容器之外的本地文件系统上提供二进制文件供下载 因此,如果Meteor应用程序位于/home/Meteor/app中,是否可以提供Meteor中/data/files的下载链接 我猜答案是否定的,因为流星似乎在它的容器中隔离了自己,但我想我会问 我不想把这些文件放在Meteor的/public中,因为它们需要放在Meteor应用程序之外的网络文件夹中。它没有直接回答问题,但我是这样做的。也许有更好的方法 Web

使用Meteor和Iron路由器,是否有Meteor模块可以方便地在Meteor应用程序容器之外的本地文件系统上提供二进制文件供下载

因此,如果Meteor应用程序位于
/home/Meteor/app
中,是否可以提供Meteor中
/data/files
的下载链接

我猜答案是否定的,因为流星似乎在它的容器中隔离了自己,但我想我会问


我不想把这些文件放在Meteor的
/public
中,因为它们需要放在Meteor应用程序之外的网络文件夹中。

它没有直接回答问题,但我是这样做的。也许有更好的方法

WebApp.connectHandlers.use('/filename.txt', function(req, res, next) {
  //the filename in the url and the filename on disk don't have to be
  //the same but I made them the same here

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

  var data = fs.readFileSync("/path/to/filename.txt");

  //if it's in the project's private directory,
  //or if you are working in a package and you added filename.txt with addAssets
  //you can probably just use
  //var data = Assets.getBinary("filename.txt");

  res.write(data);
  res.end();

});

我认为可以使用这个包从外部为文件提供服务:我对CollectionFS的理解是,它使用MongoDB存储关于每个文件的信息,包括每个文件在文件系统中的位置。我希望有一些不使用数据库的东西——只是从我指向的文件中获取信息。但这是可行的。