Error: incorrect header check when running post

前端 未结 1 1944
春和景丽
春和景丽 2021-01-15 08:57

I need to get zip from rest call (for simulation I use postman with binary option for post and add a little zip file with folder and html file),during the simulation I want

相关标签:
1条回答
  • 2021-01-15 09:38

    zlib is meant to extract gzipped or deflated data, not .ZIP files.

    You can use the node-unzip module for those:

    var unzip = require('unzip');
    ...
    app.post('/', function(req, res) {
      var extractor = unzip.Extract({ path : 'C://myFolder' }).on('close', function() {
        res.sendStatus(200);
      }).on('error', function(err) {
        res.sendStatus(500);
      });
      req.pipe(extractor);
    });
    

    If Postman can't handle uploads like this (as suggested in the comments), you can test using cURL:

    $ curl -XPOST localhost:3000 --data-binary @test.zip
    
    0 讨论(0)
提交回复
热议问题