Comments (8)
We just need a streamx -> browser stream general module. prop not too hard :)
from tar-stream.
In the meantime, I recommend using https://www.npmjs.com/package/readable-web-to-node-stream and https://www.npmjs.com/package/readable-stream-node-to-web
from tar-stream.
There's Native support for WebStreams un Node.js, we should use them instead of third-party modules.
from tar-stream.
don't know much about browser streams, but if you share some docs on them, mb we can make a wrapper
from tar-stream.
https://developer.mozilla.org/en-US/docs/Web/API/Streams_API/Concepts
MDN has the docs for readable streams. unfortunately I'm a little less versed on these as well, but happy to help implement them @mafintosh
from tar-stream.
Any update on this? I have the exact same need / problem
from tar-stream.
+1 on this
from tar-stream.
readable-web-to-node-stream appears to no longer be maintained, and fails to build in Webpack for me. I was able to use @smessie/readable-web-to-node-stream instead
Example code
Install dependencies:
npm i tar-stream @smessie/readable-web-to-node-stream
npm i -D @types/tar-stream
Content script:
const worker = new Worker('worker.js');
// User picks a file - we convert the file to a stream, and give it to a web worker:
const fileStream = file.stream();
worker.postMessage({ fileStream }, [fileStream]);
Web worker:
import { ReadableWebToNodeStream } from '@smessie/readable-web-to-node-stream';
import type { Readable } from 'node:stream';
import tar from 'tar-stream';
self.addEventListener('message', async (event) => {
const fileStream: ReadableStream<Uint8Array> = event.data.fileStream;
const decompressionStream = new DecompressionStream('gzip');
const decompressedStream = fileStream.pipeThrough(decompressionStream);
const extract = tar.extract();
const nodeStream = new ReadableWebToNodeStream(decompressedStream) as unknown as Readable;
nodeStream.pipe(extract);
for await (const entry of extract) {
console.log(entry.header.type, entry.header.name)
entry.resume();
}
});
from tar-stream.
Related Issues (20)
- all entry name are paxheader HOT 2
- "Invalid tar header: unknown format." from valid tar file, IANA tz database HOT 5
- Tar file is corrupted when using single File larger than 8 GB - tar-fs HOT 1
- Packing files at the root HOT 1
- File corrupted when combining extract with gzip HOT 2
- unable to use stream.pipeline() HOT 1
- doesn't work with HOT 2
- skipping on entry, header errors HOT 1
- zero-sized files in tarballs do not call `end` handler HOT 2
- error handling issue HOT 3
- Add browser support HOT 12
- Error: Writable stream closed prematurely HOT 1
- Missing fast-fifo dependency HOT 2
- Error: Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped? HOT 4
- create entry with base-256 size HOT 3
- Invalid tar header: unknown format. (for ExtendedName)
- Is it possible to return raw file offsets from within the tar? HOT 6
- Uncatchable error in pack.entry HOT 3
- Benchmarks not maintained in tar-fs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tar-stream.