什么是Meteor服务器端路径/ public? [英] What is the Meteor server-side path to /public?

查看:126
本文介绍了什么是Meteor服务器端路径/ public?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在流星客户端,我知道项目的公共目录中的文件被引用在'/'。



在服务器端如何引用它们?



我正在尝试使用fs.readdir获取目录列表,但是我不知道如何构建路径,以获得服务器端等同于客户端侧面'/图像/画廊'。



任何建议?

解决方案

当我使用fs-module时,我只是使用'./public'作为我的公用文件夹,在本地安装时可以正常工作。



然后我将它设置为任何在生产服务器上使用环境变量正确。



编辑(示例):



此方法将从公用文件夹返回所有.HTML文件:

  getHtmlFilesInPublicFolder:function(){

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

var cleaningUpFiles = _(files).reject(function(fileName){
return fileName.indexOf('。html')< 0;
});

return cleanUpFiles;

}


On the Meteor client-side, I know that files in the project's public directory are referenced at '/'.

How are they referenced on the server-side?

I am trying to get a directory listing with fs.readdir, but I don't know how to construct the path to get to the server side equivalent of the client side '/images/gallery'.

Any advice?

解决方案

When I use the fs-module I just use './public' for my public folder, works fine on my local install.

And then I set it to whatever's correct at the production server using environment vars.

Edit (an example):

This method will return all .HTML files from the public folder:

getHtmlFilesInPublicFolder: function() {

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

    var cleanedUpFiles = _(files).reject( function(fileName) {
        return fileName.indexOf('.html') < 0;
    });

    return cleanedUpFiles;

}

这篇关于什么是Meteor服务器端路径/ public?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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