我是sails.js
的初学者,我需要为现有服务器添加一些逻辑。
我需要从共享网络中检索图像,因此我在其中添加了ImageController.js
和操作:
module.exports = {
download: function(req, res) {
var run = req.param('run');
var test = req.param('test');
var file = req.param('file');
var path = util.format('\\\\tch-smain\\Share\\AutoTest\\Screenshots\\%s\\%s\\%s.jpeg', run, test, file);
fileAdapter.read(path)
.on('error', function (err){
return res.serverError(err);
})
.pipe(res);
}
};
然后我在config\routes.js
注册路线:
'/img': 'ImageController.download'
但是当我尝试执行GET /img?run=a&test=b&file=c
时,我收到500错误内部服务器错误。有些东西不在这里。
但是\\tch-smain\Share\AutoTest\Screenshots\a\b\c.jpeg
上的文件存在