I have a binary zip file as response from an api call. I want to download the zip file directly using Javascript/React. How can I achieve this goal?
P粉4389183232024-04-03 10:37:23
Read this FileReader and try this function: < /p>
function readFile(binaryFile) { let reader = new FileReader(); reader.readAsArrayBuffer(binaryFile); // in success case, do something with result reader.onload = function() { console.log(reader.result); }; // in error case, do something with result reader.onerror = function() { console.log(reader.error); }; }
with best regards!