Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/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_Reactjs_React Router_Meteor React - Fatal编程技术网

Meteor 流星+;反应+;路由器文件上传

Meteor 流星+;反应+;路由器文件上传,meteor,reactjs,react-router,meteor-react,Meteor,Reactjs,React Router,Meteor React,我目前正在使用Meteor、ReactJS和ReactRouter(用于路由)开发一个应用程序。我有一个要求,用户应该能够上传一个压缩的网站和流星应用程序需要显示这个网站的一部分,它的网页 一个典型的zip文件将包含如下类似的模式 ZippedFolder |-- css | |-- bootstrap.css | |-- bootstrap.min.css | +-- style.css |-- js | |-- boo

我目前正在使用Meteor、ReactJS和ReactRouter(用于路由)开发一个应用程序。我有一个要求,用户应该能够上传一个压缩的网站和流星应用程序需要显示这个网站的一部分,它的网页

一个典型的zip文件将包含如下类似的模式

ZippedFolder
    |-- css
    |    |-- bootstrap.css
    |    |-- bootstrap.min.css 
    |    +-- style.css
    |-- js
    |    |-- bootstrap.js
    |    |-- bootstrap.min.js
    |    +-- script.js 
    +- index.html
我已经设置了CollectionFS将zip文件存储到文件系统中,并且使用meteorhacks:npm和几个npm包,我能够将该文件解压缩到一个已知的位置

HTMLContent=new FS.Collection(“html\u内容”{
stores:[新的FS.Store.FileSystem(“html_内容”]
});
HTMLContent.on('stored',Meteor.bindEnvironment(函数(fileObj)){
让unzip=Meteor.npmRequire('unzip'),
fs=流星npmRequire('fs'),
path=fs.realpathSync(process.cwd()+'/../../../../../cfs/files/html_content/'),
file=fs.realpathSync(path+'/'+fileObj.copies.html_content.key),
输出=路径+'/'+fileObj.\u id;
//TODO:不是选择路径的最佳方法。仅用于演示。
如果(!fs.existsSync(输出)){
fs.mkdirSync(输出);
}
fs.createReadStream(文件).pipe(unzip.Extract({
路径:输出
}));
})); 
在React组件上,我使用以下代码片段上传压缩的HTML内容

handleZIPUpload(事件){
eachFile(事件、函数(文件){
插入(文件,函数(err,fileObj){
如果(错误){
控制台日志(err);
}否则{
console.log(fileObj);
}
});
});
},
render(){
返回(
)
}
上传和解压都可以。但是,CollectionFS不提供HTML或解压路径中的其他内容

 http://meteorhost/cfs/files/html_content/file_id/index.html
我还尝试将html内容解压缩到meteor文件夹结构的公用文件夹中。但是,meteor文档说明公用文件夹用于静态资产。因为它在公用文件夹中维护资产的索引。因此需要重新启动服务器以更新索引

是否有任何其他位置,我可以放置的HTML内容,可以作为是

更新我通过设置一个nginx虚拟目录并将文件上传到该位置,使nginx能够提供HTML内容,从而解决了这个问题