Skip to content

Support Promise[Blob].#318

Merged
dduponchel merged 1 commit intoStuk:masterfrom
dduponchel:promise_blob
Jul 27, 2016
Merged

Support Promise[Blob].#318
dduponchel merged 1 commit intoStuk:masterfrom
dduponchel:promise_blob

Conversation

@dduponchel
Copy link
Copy Markdown
Contributor

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);
    });
});

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);
    });
});
```
@dduponchel dduponchel merged commit a9d2263 into Stuk:master Jul 27, 2016
@dduponchel dduponchel deleted the promise_blob branch July 27, 2016 18:23
@dduponchel dduponchel mentioned this pull request Aug 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants