JSON Zip Response in node.js

前端 未结 3 621
一向
一向 2021-02-04 18:04

I\'m pretty new to node.js and I\'m trying to send back a zip file containing JSON results. I\'ve been trying to figure it out how to do it, but haven\'t had the expected result

3条回答
  •  无人共我
    2021-02-04 18:46

    You can compress output in express 3 with this:

    app.configure(function(){
      //....
      app.use(express.compress());
    });
    
    
    app.get('/foo', function(req, res, next){
      res.send(json_data);
    });
    

    If the user agent supports gzip it will gzip it for you automatically.

提交回复
热议问题