Last active
June 17, 2016 17:05
-
-
Save montyr75/e61180b3ff206a693538 to your computer and use it in GitHub Desktop.
Automatically send a string in the form of a downloaded file to a browser client using new HTML5 anchor attributes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void downloadFileToClient(String filename, String text) { | |
AnchorElement tempLink = document.createElement('a'); | |
tempLink | |
..attributes['href'] = 'data:text/plain;charset=utf-8,${Uri.encodeComponent(text)}' | |
..attributes['download'] = filename | |
..click(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment