Skip to content

Commit aef241e

Browse files
Updates for blob from 5.0 (#2938)
1 parent 1eb57b1 commit aef241e

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

source/api/utilities/blob.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,26 @@ cy.Blob.method() // Errors, cannot be chained off 'cy'
3030

3131
## Image Fixture
3232

33-
**Using an image fixture**
33+
### Using an image fixture for jQuery plugin upload
3434

3535
```javascript
3636
// programmatically upload the logo
3737
cy.fixture('images/logo.png').as('logo')
3838
cy.get('input[type=file]').then(function($input) {
3939
// convert the logo base64 string to a blob
40-
return Cypress.Blob.base64StringToBlob(this.logo, 'image/png')
41-
.then((blob) => {
42-
// pass the blob to the fileupload jQuery plugin
43-
// used in your application's code
44-
// which initiates a programmatic upload
45-
$input.fileupload('add', { files: blob })
46-
})
40+
const blob = Cypress.Blob.base64StringToBlob(this.logo, 'image/png')
41+
42+
// pass the blob to the fileupload jQuery plugin
43+
// https://github.com/blueimp/jQuery-File-Upload
44+
// used in your application's code
45+
// which initiates a programmatic upload
46+
$input.fileupload('add', { files: blob })
4747
})
4848
```
4949

5050
## Getting dataUrl string
5151

52-
**Create an `img` element and set its `src` to the `dataUrl`**
52+
### Create an `img` element and set its `src` to the `dataUrl`
5353

5454
```javascript
5555
return Cypress.Blob.imgSrcToDataURL('/assets/img/logo.png').then((dataUrl) => {
@@ -63,6 +63,11 @@ return Cypress.Blob.imgSrcToDataURL('/assets/img/logo.png').then((dataUrl) => {
6363
})
6464
```
6565

66+
{% history %}
67+
{% url "5.0.0" changelog %} | Return type of `arrayBufferToBlob`, `base64StringToBlob`, `binaryStringToBlob`, and `dataURLToBlob` methods changed from `Promise<Blob>` to `Blob`
68+
{% url "5.0.0" changelog %} | Added `arrayBufferToBinaryString`, `binaryStringToArrayBuffer` methods.
69+
{% endhistory %}
70+
6671
# See also
6772

68-
- {% url 'Bundled Tools' bundled-tools %}
73+
- {% url 'Bundled Tools' bundled-tools %}

0 commit comments

Comments
 (0)