Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it allowed to add a file providing a ReadableStream? #891

Open
BlueSialia opened this issue Feb 23, 2023 · 2 comments
Open

Is it allowed to add a file providing a ReadableStream? #891

BlueSialia opened this issue Feb 23, 2023 · 2 comments

Comments

@BlueSialia
Copy link

The function JSZip.file accepts as data an object of the type InputByType. Which can be stream: NodeJS.ReadableStream according to the type definitions. The documentation also states that data can be of the type NodeJS stream.

Now, I am getting the error Can't read the data of '[filename]'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ? when I provide a Readable object.

The error comes from the function prepareContent in the file lib/utils.js because the return value of exports.getTypeOf(data) is undefined. Debugging I've confirmed that data is a Readable but I see that the function exports.getTypeOf has no checks for streams. Just strings, arrays, nodebuffers, uint8arrays and arraybuffers.

I have also noticed that the value exports.nodestream from lib/support.js is not used anywhere.

So, is it an unfinished feature? Or am I doing something wrong?

@jaxalo
Copy link

jaxalo commented Apr 3, 2023

Up

@zenstok
Copy link

zenstok commented Feb 1, 2024

The syntax is like this:

   zip.file(`file-from-readable-stream.txt`, readableStream);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants