Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

二进制文件支持 #77

Open
270584936 opened this issue Apr 28, 2016 · 1 comment
Open

二进制文件支持 #77

270584936 opened this issue Apr 28, 2016 · 1 comment

Comments

@270584936
Copy link

270584936 commented Apr 28, 2016

utils.js中的normalizeData为什么不支持二进制的数据呢?res.json 已经有针对json数据的处理了,这里可以考虑支持二进制的数据否。

end: function end(data) {
      callback(_status, headers, normalizeData(data));
      return this;
    }

  function normalizeData(data) {
    switch (typeof data === 'undefined' ? 'undefined' : _typeof(data)) {
      case 'string':
        return data;
      default:
        return JSON.stringify(data);
    }
  }
`

 '/custom-func/:action': function(req, res) {
res.type(path);
fs.readFile(path, function (err, data) {
        if (err) {
            res.status(404);
            res.end("404");
            return;
        }
        res.type(srcDir + pathName)
        if (S(mime.lookup(path)).startsWith('image/')) {
            res.end(data);
        } else {
            res.end(data.toString());
        }
    });
}
@sorrycc
Copy link
Member

sorrycc commented Apr 28, 2016

@pigcan 有空看下。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants