【问题标题】:how can i abort request from a stream without losing data?(node.js)如何在不丢失数据的情况下中止流中的请求?(node.js)
【发布时间】:2017-10-26 03:23:07
【问题描述】:

我想录制 IP 摄像机视频,我有录制和停止录制按钮。 当我按下录制按钮时,我可以录制视频。 但是当我按下停止记录时,我不知道如何停止请求。 我使用 request.abort()。它可以停止请求,但也可以删除我下载的数据。 网络摄像头开启http://192.168.0.55:8080

filename = './video1.ogg';
file = fs.createWriteStream(filename);
if(req.body.record == 1) //recording
{
    theRequest = request('http://192.168.0.55:8080/');
    theRequest.pipe(file);
}
else if(req.body.record == 0) //stop recording
{
    theRequest.abort();
}

谢谢你的帮助

【问题讨论】:

    标签: node.js stream request pipe


    【解决方案1】:
    else if(req.body.record == 0) //stop recording
    {
        theRequest.pause();//add pause will solve this problem
        theRequest.abort();
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-12
      • 2017-04-07
      • 1970-01-01
      • 1970-01-01
      • 2012-09-26
      • 1970-01-01
      • 2023-03-08
      • 2012-04-30
      相关资源
      最近更新 更多