A module to stream the contents of ZIP archives through a HTTP server.
This module is based on unzipper
by @ZJONSSON, it currently does not support partial zip deflating and multi part zip files.
npm install
npm start
HTTP server routes are explained in the Router docs
const zipHttp = require('zip-http')
const express = require('express')
const app = express()
app.use(zipHttp.router())
const port = process.env.PORT || 7879
app.listen(port, () => {
console.log(`http://127.0.0.1:${port}/stream`)
})
This adds the following routes:
/create
- POST - expects an array of URLs to ZIP files, replies with{"key":"fiql"}
/stream
- GET - expects akey=
(key from/create
), it also supportso=
for a JSON stringified list of Options
const fs = require('fs')
const zipHttp = require('zip-http')
async function getZipStream() {
const key = zipHttp.create([
'http://test.com/file.zip'
])
const file = await zipHttp.file(key, {
fileMustInclude: ['Lorem Ipsum'],
maxFiles: 1
})
file
.createReadStream()
.pipe(
fs.createWriteStream(`./${file.name}`)
)
}
getRarStream()
-
zipHttp.create()
requires an array of strings with HTTP(s) URLs to ZIP files, it return akey
which is meant to be used with the.file()
method -
zipHttp.file(key, opts)
supports the same Options as the/stream
endpoint,key
is required, butopts
is optional
Options:
{
"fileIdx": 1,
"fileMustInclude": ["/dexter/i", "the hulk"]
}
fileIdx
- integer - selects the file that matches the index in the ZIP archivefileMustInclude
- array of strings (can also be RegExp string) - selects the first file that includes any of the matches
built with love and serious coding skills by the Stremio Team