You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"use strict";fetch("/jszip/test/ref/text.zip")// 1) fetch the url.then(function(response){// 2) filter on 200 OKif(response.status===200||response.status===0){returnPromise.resolve(response.blob());}else{returnPromise.reject(newError(response.statusText));}}).then(JSZip.loadAsync)// 3) chain with the zip promise.then(function(zip){returnzip.file("Hello.txt").async("string");// 4) chain with the text content promise}).then(functionsuccess(text){// 5) display the result$("#fetch").append($("<p>",{"class": "alert alert-success",text: "loaded, content = "+text}));},functionerror(e){$("#fetch").append($("<p>",{"class": "alert alert-danger",text: e}));});
The code fails:
jszip@3.10.1/node_modules/jszip/lib/utils.js:479
new Error("Can't read the data of '" + name + "'. Is it " +
^
Error: Can't read the data of 'the loaded zip file'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?
The text was updated successfully, but these errors were encountered:
Michael-1
changed the title
Reading blob on nodejs fails
Reading blob on NodeJs fails
Jun 1, 2023
I found this bug today. Here is a shorter reproducing sample:
npm i jszip
echo'Hello World'> hello.txt && zip hello.zip hello.txt
node -e "require('jszip').loadAsync(new Blob([require('fs').readFileSync('hello.zip')]));"
/home/ulysses/temp/jszip-test/node_modules/jszip/lib/utils.js:479
new Error("Can't read the data of '" + name + "'. Is it " +
^
Error: Can't read the data of 'the loaded zip file'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?
at /home/ulysses/temp/jszip-test/node_modules/jszip/lib/utils.js:479:17
Node.js v18.16.0
I’m executing the example code for get a file with an Ajax call on NodeJS 18:
The code fails:
The text was updated successfully, but these errors were encountered: