Get contents of a zip file Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!How can I upload files asynchronously?How do you get a timestamp in JavaScript?How to get the children of the $(this) selector?Get current URL with jQuery?How can I get query string values in JavaScript?How do I include a JavaScript file in another JavaScript file?Get the current URL with JavaScript?How do I get the current date in JavaScript?Get selected text from a drop-down list (select box) using jQueryPdf download from url, save it in a file, zip then download the zip

Should man-made satellites feature an intelligent inverted "cow catcher"?

How do I overlay a PNG over two videos (one video overlays another) in one command using FFmpeg?

/bin/ls sorts differently than just ls

When does Bran Stark remember Jamie pushing him?

Why do people think Winterfell crypts is the safest place for women, children & old people?

Why does my GNOME settings mention "Moto C Plus"?

A German immigrant ancestor has a "Registration Affidavit of Alien Enemy" on file. What does that mean exactly?

Would I be safe to drive a 23 year old truck for 7 hours / 450 miles?

Assertions In A Mock Callout Test

Coin Game with infinite paradox

Do chord progressions usually move by fifths?

Does GDPR cover the collection of data by websites that crawl the web and resell user data

How can I introduce the names of fantasy creatures to the reader?

lm and glm function in R

How to get a single big right brace?

Does using the Inspiration rules for character defects encourage My Guy Syndrome?

What is the definining line between a helicopter and a drone a person can ride in?

Reflections in a Square

Is there a way to convert Wolfram Language expression to string?

Can I ask an author to send me his ebook?

Are bags of holding fireproof?

Kepler's 3rd law: ratios don't fit data

What is the difference between 准时 and 按时?

Why did Israel vote against lifting the American embargo on Cuba?



Get contents of a zip file



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!How can I upload files asynchronously?How do you get a timestamp in JavaScript?How to get the children of the $(this) selector?Get current URL with jQuery?How can I get query string values in JavaScript?How do I include a JavaScript file in another JavaScript file?Get the current URL with JavaScript?How do I get the current date in JavaScript?Get selected text from a drop-down list (select box) using jQueryPdf download from url, save it in a file, zip then download the zip



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















This URL below points to a zip file which contains a file called bundlesizes.json. I am trying to read the contents of that json file within my React application (no node server/backend involved)



https://dev.azure.com/uifabric/cd9e4e13-b8db-429a-9c21-499bf1c98639/_apis/build/builds/8838/artifacts?artifactName=drop&api-version=4.1&%24format=zip


I was able to get the contents of the zip file by doing the following



const url =
'https://dev.azure.com/uifabric/cd9e4e13-b8db-429a-9c21-499bf1c98639/_apis/build/builds/8838/artifacts?artifactName=drop&api-version=4.1&%24format=zip';
const response = await Axios(
url,
method: 'GET',
responseType: 'stream'
);
console.log(response.data);


This emits the zip file (non-ascii characters). However, I am looking to read the contents of the bundlesizes.json file within it.



For that I looked up jszip and tried the following,



var zip = new JSZip();
zip.createReader(
new zip.BlobReader(response.data),
function(reader: any)
// get all entries from the zip
reader.getEntries(function(entries: any)
if (entries.length)
// get first entry content as text
entries[0].getData(
new zip.TextWriter(),
function(text: any)
// text contains the entry data as a String
console.log(text);

// close the zip reader
reader.close(function()
// onclose callback
);
,
function(current: any, total: any)
// onprogress callback
console.log(current);
console.log(total);

);

);
,
function(error: any)
// onerror callback
console.log(error);

);


However, this does not work for me, and errors out.
This is the error I receive



enter image description here



How can I read the contents of the file within the zip within my React application by using Javascript/Typescript?










share|improve this question




























    1















    This URL below points to a zip file which contains a file called bundlesizes.json. I am trying to read the contents of that json file within my React application (no node server/backend involved)



    https://dev.azure.com/uifabric/cd9e4e13-b8db-429a-9c21-499bf1c98639/_apis/build/builds/8838/artifacts?artifactName=drop&api-version=4.1&%24format=zip


    I was able to get the contents of the zip file by doing the following



    const url =
    'https://dev.azure.com/uifabric/cd9e4e13-b8db-429a-9c21-499bf1c98639/_apis/build/builds/8838/artifacts?artifactName=drop&api-version=4.1&%24format=zip';
    const response = await Axios(
    url,
    method: 'GET',
    responseType: 'stream'
    );
    console.log(response.data);


    This emits the zip file (non-ascii characters). However, I am looking to read the contents of the bundlesizes.json file within it.



    For that I looked up jszip and tried the following,



    var zip = new JSZip();
    zip.createReader(
    new zip.BlobReader(response.data),
    function(reader: any)
    // get all entries from the zip
    reader.getEntries(function(entries: any)
    if (entries.length)
    // get first entry content as text
    entries[0].getData(
    new zip.TextWriter(),
    function(text: any)
    // text contains the entry data as a String
    console.log(text);

    // close the zip reader
    reader.close(function()
    // onclose callback
    );
    ,
    function(current: any, total: any)
    // onprogress callback
    console.log(current);
    console.log(total);

    );

    );
    ,
    function(error: any)
    // onerror callback
    console.log(error);

    );


    However, this does not work for me, and errors out.
    This is the error I receive



    enter image description here



    How can I read the contents of the file within the zip within my React application by using Javascript/Typescript?










    share|improve this question
























      1












      1








      1


      1






      This URL below points to a zip file which contains a file called bundlesizes.json. I am trying to read the contents of that json file within my React application (no node server/backend involved)



      https://dev.azure.com/uifabric/cd9e4e13-b8db-429a-9c21-499bf1c98639/_apis/build/builds/8838/artifacts?artifactName=drop&api-version=4.1&%24format=zip


      I was able to get the contents of the zip file by doing the following



      const url =
      'https://dev.azure.com/uifabric/cd9e4e13-b8db-429a-9c21-499bf1c98639/_apis/build/builds/8838/artifacts?artifactName=drop&api-version=4.1&%24format=zip';
      const response = await Axios(
      url,
      method: 'GET',
      responseType: 'stream'
      );
      console.log(response.data);


      This emits the zip file (non-ascii characters). However, I am looking to read the contents of the bundlesizes.json file within it.



      For that I looked up jszip and tried the following,



      var zip = new JSZip();
      zip.createReader(
      new zip.BlobReader(response.data),
      function(reader: any)
      // get all entries from the zip
      reader.getEntries(function(entries: any)
      if (entries.length)
      // get first entry content as text
      entries[0].getData(
      new zip.TextWriter(),
      function(text: any)
      // text contains the entry data as a String
      console.log(text);

      // close the zip reader
      reader.close(function()
      // onclose callback
      );
      ,
      function(current: any, total: any)
      // onprogress callback
      console.log(current);
      console.log(total);

      );

      );
      ,
      function(error: any)
      // onerror callback
      console.log(error);

      );


      However, this does not work for me, and errors out.
      This is the error I receive



      enter image description here



      How can I read the contents of the file within the zip within my React application by using Javascript/Typescript?










      share|improve this question














      This URL below points to a zip file which contains a file called bundlesizes.json. I am trying to read the contents of that json file within my React application (no node server/backend involved)



      https://dev.azure.com/uifabric/cd9e4e13-b8db-429a-9c21-499bf1c98639/_apis/build/builds/8838/artifacts?artifactName=drop&api-version=4.1&%24format=zip


      I was able to get the contents of the zip file by doing the following



      const url =
      'https://dev.azure.com/uifabric/cd9e4e13-b8db-429a-9c21-499bf1c98639/_apis/build/builds/8838/artifacts?artifactName=drop&api-version=4.1&%24format=zip';
      const response = await Axios(
      url,
      method: 'GET',
      responseType: 'stream'
      );
      console.log(response.data);


      This emits the zip file (non-ascii characters). However, I am looking to read the contents of the bundlesizes.json file within it.



      For that I looked up jszip and tried the following,



      var zip = new JSZip();
      zip.createReader(
      new zip.BlobReader(response.data),
      function(reader: any)
      // get all entries from the zip
      reader.getEntries(function(entries: any)
      if (entries.length)
      // get first entry content as text
      entries[0].getData(
      new zip.TextWriter(),
      function(text: any)
      // text contains the entry data as a String
      console.log(text);

      // close the zip reader
      reader.close(function()
      // onclose callback
      );
      ,
      function(current: any, total: any)
      // onprogress callback
      console.log(current);
      console.log(total);

      );

      );
      ,
      function(error: any)
      // onerror callback
      console.log(error);

      );


      However, this does not work for me, and errors out.
      This is the error I receive



      enter image description here



      How can I read the contents of the file within the zip within my React application by using Javascript/Typescript?







      javascript typescript axios fetch jszip






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 9 at 2:11









      tubbytubby

      81911331




      81911331






















          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55073330%2fget-contents-of-a-zip-file%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55073330%2fget-contents-of-a-zip-file%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

          Алба-Юлія

          Захаров Федір Захарович