Download the ZIP file in response to the api call
P粉034571623
P粉034571623 2024-04-02 13:56:27
0
1
343

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粉034571623
P粉034571623

reply all(1)
P粉438918323

Read this FileReader and try this function:

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!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!