Support Promise[Blob]. #318

Merged
merged 1 commit into from Jul 27, 2016

Projects

None yet

1 participant

@dduponchel
Collaborator

The old code didn't accept promises containing blobs which cause issues
when working with canvas. There are two ways to get a binary content from
a canvas: canvas.toDataURL() and canvas.toBlob(). Working with the
first one involves a substring to remove the data url part and a base64
decode. The other one ends up with a Promise[Blob], fixed by this
commit. Now, we can extract the binary content of a canvas like:

var p = new JSZip.external.Promise(function (resolve, reject) {
    canvas.toBlob(function (blob) {
        resolve(blob);
    });
});
@dduponchel dduponchel Support Promise[Blob].
The old code didn't accept promises containing blobs which cause issues
when working with canvas. There are two ways to get a binary content from
a canvas: `canvas.toDataURL()` and `canvas.toBlob()`. Working with the
first one involves a substring to remove the data url part and a base64
decode. The other one ends up with a Promise[Blob], fixed by this
commit. Now, we can extract the binary content of a canvas like:

```js
var p = new JSZip.external.Promise(function (resolve, reject) {
    canvas.toBlob(function (blob) {
        resolve(blob);
    });
});
```
af944ad
@dduponchel dduponchel merged commit a9d2263 into Stuk:master Jul 27, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@dduponchel dduponchel deleted the dduponchel:promise_blob branch Jul 27, 2016
@dduponchel dduponchel referenced this pull request Aug 2, 2016
Merged

Release v3.1.0 #326

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment