[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/js/dist/ -> blob.js (summary)

(no description)

File Size: 159 lines (5 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 6 functions

  createBlobURL()
  getBlobByURL()
  getBlobTypeByURL()
  revokeBlobURL()
  isBlobURL()
  downloadBlob()

Functions
Functions that are not part of a class:

createBlobURL(file)   X-Ref
Create a blob URL from a file.

param: {File} file The file to create a blob URL for.
return: {string} The blob URL.

getBlobByURL(url)   X-Ref
Retrieve a file based on a blob URL. The file must have been created by
`createBlobURL` and not removed by `revokeBlobURL`, otherwise it will return
`undefined`.

param: {string} url The blob URL.
return: {File|undefined} The file for the blob URL.

getBlobTypeByURL(url)   X-Ref
Retrieve a blob type based on URL. The file must have been created by
`createBlobURL` and not removed by `revokeBlobURL`, otherwise it will return
`undefined`.

param: {string} url The blob URL.
return: {string|undefined} The blob type.

revokeBlobURL(url)   X-Ref
Remove the resource and file cache from memory.

param: {string} url The blob URL.

isBlobURL(url)   X-Ref
Check whether a url is a blob url.

param: {string|undefined} url The URL.
return: {boolean} Is the url a blob url?

downloadBlob(filename, content, contentType = '')   X-Ref
Downloads a file, e.g., a text or readable stream, in the browser.
Appropriate for downloading smaller file sizes, e.g., < 5 MB.

Example usage:

```js
const fileContent = JSON.stringify(
{
"title": "My Post",
},
null,
2
);
const filename = 'file.json';

downloadBlob( filename, fileContent, 'application/json' );
```

param: {string}   filename    File name.
param: {BlobPart} content     File content (BufferSource | Blob | string).
param: {string}   contentType (Optional) File mime type. Default is `''`.



Generated : Mon Mar 18 08:20:01 2024 Cross-referenced by PHPXref