workhorsy / uncompress.js

Uncompress ZIP, RAR, and TAR files with pure JavaScript
http://workhorsy.github.io/uncompress.js/examples
MIT License
106 stars 17 forks source link

Rar file not being recognized #15

Closed cfjedimaster closed 6 years ago

cfjedimaster commented 6 years ago

I'm building a drag/drop reader for CBR/CBZ files. I'm using this code to dynamically switch between working w/ a rar or zip based on the extension (and yeah, the check is a bit lame):

function handleFile(file) {
    console.log('try to parse '+file.name);
    let fileReader = new FileReader();
    let ext = ".zip";
    if(file.name.indexOf(".cbr") >= 0) {
        //above should check END of name, not anywhere
        ext = ".rar";
    }
    console.log('This is a '+ext);
    fileReader.onload = function() {
        console.log('onload');
        let array_buffer = this.result;
        console.log(array_buffer);
        let archive = archiveOpenArrayBuffer("example_rar_5"+ext, null, array_buffer);
        if (archive) {
            console.info('Uncompressing ' + archive.archive_type + ' ...');
            console.dir(archive);
            //onArchiveLoaded(archive);
        } else {
            //console.error(err);
        }
    }
    fileReader.readAsArrayBuffer(file);

I can confirm that dropping a cbz file works fine, but dropping a cbr gives me: Error: The archive type is unknown.

Any idea why?

cfjedimaster commented 6 years ago

I'm sorry - it must have been a bad CBR. I tried another and it worked well.

workhorsy commented 6 years ago

That is okay. Thanks for testing this though.

cfjedimaster commented 6 years ago

FYI - built this with your stuff: https://www.raymondcamden.com/2018/02/28/building-an-html5-comic-book-reader-in-2018/

workhorsy commented 6 years ago

Nice! Glad to see more people making comic book readers in the browser.