InvokIT / js-untar

Library for reading tar files in the browser.
MIT License
78 stars 33 forks source link

Get wrong result #10

Closed cristian-sima closed 6 years ago

cristian-sima commented 7 years ago

Hi. I use HTML5 form to upload a tar, untar it in order to get an XML file and then upload the XML file to the server.

This is the code

const
  problemWithTheFile = "Something went wrong",
  [myArchieve] = files,
  reader = new FileReader();

// Closure to capture the file information.
reader.onload = (((theFile) => (event) => {

  untar(event.target.result).then(
    (extractedFiles) => {
      const [xmlFile] = extractedFiles;

      console.log("xmlFile.readAsString()", xmlFile.readAsString());

      // ... then I can use the XML file
    },
    () => {
      alert(problemWithTheFile);
    }
  );
})(myArchieve));

reader.readAsArrayBuffer(myArchieve);

When I look at console I see this: image

I can not upload the archive, but it contains a single XML file and it works when trying to use with other programs.

@Qvazar Any idea on this? I would really appreciate if you can help me.

Thanks

megawac commented 7 years ago

Are you openning a tar.gz file instead of a tar file?

stefanbohacek commented 1 year ago

Is there a way to handle tar.gz files as well?