# ultimate-markdown/trunk/admin/react/utils/utils.js

Ultimate Markdown – Markdown Editor, Importer, &amp; Exporter, version trunk. 29 lines.

- Page: https://pluginprobe.com/plugins/ultimate-markdown/trunk/code/admin/react/utils/utils.js
- Raw: https://pluginprobe.com/plugins/ultimate-markdown/trunk/raw/admin/react/utils/utils.js
- Modified: 2025-12-21T11:39:50+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/ultimate-markdown/trunk/code/admin/react/utils/utils.js#L10-L20`.

```javascript
/**
 * Download a file from the provided string.
 *
 * @param content
 * @param fileNamePrefix
 */
export const downloadFileFromString = (content, fileNamePrefix) => {

    const blob = content;

    // Create a temporary URL to the blob.
    const url = window.URL.createObjectURL(new Blob([blob]));

    // Create a link element.
    const link = document.createElement('a');
    link.href = url;
    const fileName = fileNamePrefix + '-' + Date.now().toString().slice(0, 10) + '.csv';
    link.setAttribute('download', fileName); // Specify the filename

    // Append the link to the body.
    document.body.appendChild(link);

    // Trigger the click event on the link.
    link.click();

    // Cleanup.
    link.parentNode.removeChild(link);

}
```
