Извлечение одного файла из удаленного потока Piped в unzip.Parse () с использованием NodeJ без чтения всего потока - PullRequest
0 голосов
/ 02 мая 2018

Я использую NodeJs "torrent-stream", чтобы открыть поток в торрент-файл, затем выбрать целевой Zip-файл и передать целевой файл в поток UnZip.

let torrentStream = require("torrent-stream");
let unzip = require("unzip-stream");

let engine = torrentStream(torrentMagentURL);
engine.on("ready", () => {
    //select the target zip file
    let file = engine.files[0]; 
    //open a stream to the remote zip file from torrent connection
    let stream = file.createReadStream();
    //pip the remote file to a Zip reader
    let zip = stream.pipe(unzip.Parse());
    //listen to every entry parsed from the zip file
    zip.on("entry", entry => {
            // the problem is here :: 
            // for the every entry in the zip file 
            // this call back wont be called unless 
            // all the content of the previous entry 
            // in the zip file are downloaded

            // what I really need is to SEEK to the next entry 
            // NOT download the previous entry entirely before 
            // seek to the next one. 
            // because mostly the needed file to be downloaded 
            // from the zip file wont be the first entry.

            // noting that "torrent-stream" support seeking 
            // in its remote stream.
    })
})
...