jszip
jszip copied to clipboard
Is it allowed to add a file providing a ReadableStream?
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?
Up
The syntax is like this:
zip.file(`file-from-readable-stream.txt`, readableStream);