作者guestaadd (nn)
看板Ajax
标题[node] request.abort()不删除资料
时间Thu Oct 26 14:27:33 2017
各位大大好
目前想要实现的功能为远端有一台IP camera透过VLC送stream
然後这边有一个使用node.js架的网页会开启此stream并依照情况储存影片
开启stream并储存没什麽问题
但我想要停止录影的时候,找不到适当的method使用
abort虽然可以中断,但也会把我储存的影片清空
stream格式为ogg,远方ip camera在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的网站的确也是说会把资料丢掉
https://nodejs.org/api/http.html#http_request_abort
想请问有其他method可以中断又不丢掉资料
有试过先复制一份资料,但好像因为一直pipe的关系
复制後的档案大小为0
试过lockfile也会出现error
程式码为部分内容,如有需要其他部分会再补上
谢谢
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 122.116.71.79
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Ajax/M.1508999261.A.122.html
※ 编辑: guestaadd (122.116.71.79), 10/26/2017 14:30:47
※ 编辑: guestaadd (122.116.71.79), 10/26/2017 14:31:40
1F:→ DarkKnightX: 试试看 theRequest.unpipe() ? 10/29 07:59