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
使用API中的图像并在meteor中的浏览器上显示_Meteor_Iron Router - Fatal编程技术网

使用API中的图像并在meteor中的浏览器上显示

使用API中的图像并在meteor中的浏览器上显示,meteor,iron-router,Meteor,Iron Router,我有一个API返回图像,并希望在浏览器上显示图像。我使用的是iron:router软件包。在客户端,用户点击一个基本上是服务器端的链接iron:route。路由调用API,并应在浏览器上显示API的响应 客户端js:- Template.images.events({ “click.image”:函数(事件、模板){ event.preventDefault(); var docId=$(event.target).attr('data-docId'); var imageType=“原始”;

我有一个API返回图像,并希望在浏览器上显示图像。我使用的是
iron:router
软件包。在客户端,用户点击一个基本上是服务器端的链接
iron:route
。路由调用API,并应在浏览器上显示API的响应

客户端js:-

Template.images.events({
“click.image”:函数(事件、模板){
event.preventDefault();
var docId=$(event.target).attr('data-docId');
var imageType=“原始”;
var param={“docId”:docId,“imageType”:imageType};
参数='width='+window.innerWidth;
参数+=',高度='+window.innerHeight;
参数+=',顶部=0,左侧=0'
参数+=',全屏显示=是';
var win=window.open(“/Image/?param=“+encodeURIComponent(Base64.encode(JSON.stringify(param))”,“_blank”,params);
}
});
铁:路线:-

Router.route('/checkImage',函数(){
var decoded=Base64.decode(decodeURIComponent(this.params.query.param));
var param=JSON.parse(已解码);
var docId=param.docId;
var-content=“”;
Meteor.call('imageApi',docId,imageType,函数(错误,结果){
如果(错误){
content=“”;
}否则
内容=新缓冲区(结果);
});
如果(内容==“”){
this.response.writeHeader('200'{
“内容类型”:“图像/jpeg”,
“内容处置”:“内联”,
“访问控制允许来源”:“*”
});
this.response.write(“未找到图像内容。

”); this.response.end(); } 否则{ this.response.writeHeader('200'{ “内容类型”:“图像/jpeg” “内容配置”:“内联;文件名=image.jpg” }); 这个.响应.写(内容); this.response.end(); } },{其中:'服务器'});
服务器方法:-

imageApi:function(docId,imageType){
var url=“带参数的API url”;
var反应;
试一试{
response=HTTP.call('GET',url{
标题:{“内容类型”:“图像/jpeg”},
响应类型:“缓冲区”
});
}捕获(错误){
logger.error(“imageApi-图像API中的异常”+错误);
返回false;
}
如果(response.statusCode==200){
返回新的Uint8Array(response.content);
}
否则{
logger.error“imageApi-响应问题:“+Response.statusCode”);
返回“”;
}
返回“”;
}
我无法在浏览器上显示图像数据。您是否认为这种方法有问题?或者,如果有其他方法渲染图像,是否有问题