Sails.js下载文件

时间:2016-07-05 17:53:45

标签: javascript model-view-controller filesystems sails.js

我是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上的文件存在

0 个答案:

没有答案