2

I'm making .glb viewer with a-frame. my glb file is big(around 400MB), so I'm trying to load compressed zip file (around 20MB) and decompressed it inside browser. However, pako is not working.. error log said "unknown compression method".

I zipped a file with Windows default function (right click). Am I something wrong?

    <script type="text/javascript" src="pako.min.js"></script>
</head>
<body>
<script>
AFRAME.registerComponent('compressed-zip-loader', {
    init: function () {
        try {
            fetch("2mCylinderEngine.zip").then(function (response) {
                response.blob().then(function (myBlob) {
                    try {
                        output = new pako.inflate(myBlob);
                    } catch  (err) {
                        console.log(err);  // unknown compression method
                    }
                });
             });
        } catch { 
            console.log("error");
        }
    }
});
</script>
luvzqn
  • 21
  • 2
  • You need to convert blob to array buffer...See [Answer](https://stackoverflow.com/questions/47685090/pako-not-able-to-deflate-gzip-files-generated-in-python) here – TechySharnav May 08 '21 at 09:29
  • I change `response.blob()` to `response.arrayBuffer()`.. it doesn't work with error, "incorrect header check". thanks. – luvzqn May 08 '21 at 10:42
  • Many web servers can do something called "dynamic compression" where the payload is automatically compressed over the wire. You probably don't need to be doing this manually in JavaScript on the client side, it's just a feature of the HTTP protocol that you can enable on the server side. – emackey May 08 '21 at 17:25
  • For example, if you were using Microsoft IIS, this would be the relevant documentation page: https://learn.microsoft.com/en-us/iis/configuration/system.webserver/httpcompression/ Most servers can do something like this, not just IIS. – emackey May 08 '21 at 17:29
  • Thank you for your comment, emackey. Yes,, but I want to unzip with JavaScript. Thanks. – luvzqn May 08 '21 at 18:26
  • 1
    for people landing here with similar question. emackey wrote "solution". If you want to unzip file in browser with JavaScript, drop that idea and use Microsoft IIS. Have a nice day. – luvzqn May 08 '21 at 20:38

0 Answers0