JSZip.base64.decode doesn't behave in the same way in v1.0 and 2.0 #100

Closed
edi9999 opened this Issue Feb 18, 2014 · 3 comments

Projects

None yet

2 participants

@edi9999
Contributor
edi9999 commented Feb 18, 2014

In my docxLibrary that depends on JSZip, I want to depend on JSZip2.0 now.

However, it seems that JSZip.base64.encode(data) has changed a little bit it's behaviour.

xhrDoc= new XMLHttpRequest()
xhrDoc.open('GET', 'image.png', false)
     if (xhrDoc.overrideMimeType)
            xhrDoc.overrideMimeType('text/plain; charset=x-user-defined')
    xhrDoc.onreadystatechange = function(e) {
        if (this.readyState == 4 && this.status==200)
                        data=this.response
    }
    xhrDoc.send()

base64Data=JSZip.base64.encode(data)

The code that now doesn't work is here: https://github.com/edi9999/docxtemplater/blob/master/coffee/docxQrCode.coffee

Except for the renaming of JSZipbase64 to JSZip.base64, do you remember making any changes to the encode method ?

@dduponchel
Collaborator

I don't see any change : v1.0.1, v2.1.1, and your example works for me (with a console.log(JSZip.base64.encode(this.response))) for the two versions. I see a lot of files['blabla.png'].data in your file docxgenTest.coffee. The data attribute doesn't exist anymore, you should use .asText() or .asBinary() (use this one with binary content) to get the content as a string.

Also, congrats for taking the issue #100 :)

@edi9999
Contributor
edi9999 commented Feb 18, 2014

Haha, issue #100 !

You're right, I changed the .data attributes in an other branch I haven't
yet pushed. But I was using asText everywhere where I used .data before, so
that what was wrong, I changed some of the to .asBinary() and it now works !

Thanks !

Edgar HIPP
Elève-Ingénieur BAC+5 à l'école Centrale de Lille
+33 6 52 59 35 93
about.me/edgar.hipp
MeetMe http://doodle.com/edgar.hipp

On 18 February 2014 13:09, David Duponchel notifications@github.com wrote:

I don't see any change : v1.0.1https://github.com/Stuk/jszip/blob/v1.0.1/jszip.js#L872,
v2.1.1 https://github.com/Stuk/jszip/blob/v2.1.1/lib/base64.js, and
your example works for me (with a
console.log(JSZip.base64.encode(this.response))) for the two versions. I
see a lot of files['blabla.png'].data in your file docxgenTest.coffee.
The data attribute doesn't exist anymore, you should use .asText() or
.asBinary() (use this one with binary content) to get the content as a
string.

Also, congrats for taking the issue #100#100:)


Reply to this email directly or view it on GitHubhttps://github.com/Stuk/jszip/issues/100#issuecomment-35377883
.

@dduponchel dduponchel added a commit to dduponchel/jszip that referenced this issue Feb 18, 2014
@dduponchel dduponchel migration guide : add .asBinary() to the example
Fix issue #100 : the migration guide said that the equivalent of .data
is .asText() but the utf8 conversion is not always welcomed.
973b44a
@dduponchel
Collaborator

The documentation has been updated, I'm closing this issue.

@dduponchel dduponchel closed this Feb 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment