Skip to content

Issue with IE 9 and JSZip #77

Open
@ncpavankumar

Description

@ncpavankumar

Hi

I am trying to use this fix to resolve the same issue in the application that I am working on. I am still at loss in getting a working solution. Here is my case:

I am having an ajax call for getting the zip file and setting the xhr's overrideMimeType property at beforeSend. I have included the VB Script as an inline script in the html and am trying to call the functions on success of the ajax calls. I am getting the data as binary. using this binary, I am trying to use the code provided in the test scripts to fix the IE issue.

   var url = block.url;
   return $.ajax({ url:block.url, dataType:'text',
                    beforeSend: function( xhr ) {
                        // The .zip libraries require that the stream be plain text.
                        // 
                        xhr.overrideMimeType( "text/plain; charset=x-user-defined" );
                    },
                    progress: function (jqXHR, progressEvent) {
                        if (progressEvent.lengthComputable) {
                            job.setProgress( progressEvent.loaded / progressEvent.total );
                        } else { 
                            job.setProgress( 0.5 );
                        }
                    },
                    complete: function( jqXHR, textStatus ) { 
                        job.setProgress( 1 );
                        job.done();
                    },
                    success: function(data,textStatus,jqXHR) {
        var browserVersion = threeJsHelper.getBrowserVersion();
        if(browserVersion === '>ie9') {
            var binary = data;
            var byteMapping = {};
            for ( var i = 0; i < 256; i++ ) {
                for ( var j = 0; j < 256; j++ ) {
                    byteMapping[ String.fromCharCode( i + (j << 8) ) ] = 
                                                            String.fromCharCode(i) + String.fromCharCode(j);
                }
            }

            var rawBytes = IEBinaryToArray_ByteStr(binary);
            var lastChr = IEBinaryToArray_ByteStr_Last(binary);
            var mapMatch = function(match) {
                return byteMapping[match];
            };
            var dataFile = rawBytes.replace(/[\s\S]/g, mapMatch) + lastChr; 
                                data = dataFile;
        }
        job.setProgress( 0.99 );
                        block.resourceData.rawdata = data;
                        $rootScope.$broadcast( 'loadResource', block );
                    }
                  });
};

Once the loadResource is broadcasted, I am using the rawData as jszip = new JSZip( resourceData.rawdata );
The error I see is :
Error: Corrupted zip : can't find end of central directoryundefined

Can you please advice me what is going on and where am I going wrong?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions