исходники https://github.com/eligrey/FileSaver.js

пример http://eligrey.com/demos/FileSaver.js/