[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-3097":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":16,"stars30d":17,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":18,"rankGlobal":10,"rankLanguage":10,"license":19,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":22,"hasPages":20,"topics":23,"createdAt":10,"pushedAt":10,"updatedAt":24,"readmeContent":25,"aiSummary":26,"trendingCount":16,"starSnapshotCount":16,"syncStatus":27,"lastSyncTime":28,"discoverSource":29},3097,"FileSaver.js","eligrey\u002FFileSaver.js","eligrey","An HTML5 saveAs() FileSaver implementation","https:\u002F\u002Feligrey.com\u002Fblog\u002Fsaving-generated-files-on-the-client-side\u002F",null,"JavaScript",21995,4325,352,183,0,5,70.5,"Other",false,"master",true,[],"2026-06-12 04:00:16","If you need to save really large files bigger than the blob's size limitation or don't have\nenough RAM, then have a look at the more advanced [StreamSaver.js][7]\nthat can save data directly to the hard drive asynchronously with the power of the new streams API. That will have\nsupport for progress, cancelation and knowing when it's done writing\n\nFileSaver.js\n============\n\nFileSaver.js is the solution to saving files on the client-side, and is perfect for\nweb apps that generates files on the client, However if the file is coming from the\nserver we recommend you to first try to use [Content-Disposition][8] attachment response header as it has more cross-browser compatiblity.\n\nLooking for `canvas.toBlob()` for saving canvases? Check out\n[canvas-toBlob.js][2] for a cross-browser implementation.\n\nSupported Browsers\n------------------\n\n| Browser        | Constructs as | Filenames    | Max Blob Size | Dependencies |\n| -------------- | ------------- | ------------ | ------------- | ------------ |\n| Firefox 20+    | Blob          | Yes          | 800 MiB       | None         |\n| Firefox \u003C 20   | data: URI     | No           | n\u002Fa           | [Blob.js](https:\u002F\u002Fgithub.com\u002Feligrey\u002FBlob.js) |\n| Chrome         | Blob          | Yes          | [2GB][3]      | None         |\n| Chrome for Android | Blob      | Yes          | [RAM\u002F5][3]    | None         |\n| Edge           | Blob          | Yes          | ?             | None         |\n| IE 10+         | Blob          | Yes          | 600 MiB       | None         |\n| Opera 15+      | Blob          | Yes          | 500 MiB       | None         |\n| Opera \u003C 15     | data: URI     | No           | n\u002Fa           | [Blob.js](https:\u002F\u002Fgithub.com\u002Feligrey\u002FBlob.js) |\n| Safari 6.1+*   | Blob          | No           | ?             | None         |\n| Safari \u003C 6     | data: URI     | No           | n\u002Fa           | [Blob.js](https:\u002F\u002Fgithub.com\u002Feligrey\u002FBlob.js) |\n| Safari 10.1+   | Blob          | Yes          | n\u002Fa           | None         |\n\nFeature detection is possible:\n\n```js\ntry {\n    var isFileSaverSupported = !!new Blob;\n} catch (e) {}\n```\n\n### IE \u003C 10\n\nIt is possible to save text files in IE \u003C 10 without Flash-based polyfills.\nSee [ChenWenBrian and koffsyrup's `saveTextAs()`](https:\u002F\u002Fgithub.com\u002Fkoffsyrup\u002FFileSaver.js#examples) for more details.\n\n### Safari 6.1+\n\nBlobs may be opened instead of saved sometimes—you may have to direct your Safari users to manually\npress \u003Ckbd>⌘\u003C\u002Fkbd>+\u003Ckbd>S\u003C\u002Fkbd> to save the file after it is opened. Using the `application\u002Foctet-stream` MIME type to force downloads [can cause issues in Safari](https:\u002F\u002Fgithub.com\u002Feligrey\u002FFileSaver.js\u002Fissues\u002F12#issuecomment-47247096).\n\n### iOS\n\nsaveAs must be run within a user interaction event such as onTouchDown or onClick; setTimeout will prevent saveAs from triggering. Due to restrictions in iOS saveAs opens in a new window instead of downloading, if you want this fixed please [tell Apple how this WebKit bug is affecting you](https:\u002F\u002Fbugs.webkit.org\u002Fshow_bug.cgi?id=167341).\n\nSyntax\n------\n### Import `saveAs()` from file-saver\n```js\nimport { saveAs } from 'file-saver';\n```\n\n```js\nFileSaver saveAs(Blob\u002FFile\u002FUrl, optional DOMString filename, optional Object { autoBom })\n```\n\nPass `{ autoBom: true }` if you want FileSaver.js to automatically provide Unicode text encoding hints (see: [byte order mark](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FByte_order_mark)). Note that this is only done if your blob type has `charset=utf-8` set.\n\nExamples\n--------\n\n### Saving text using `require()`\n```js\nvar FileSaver = require('file-saver');\nvar blob = new Blob([\"Hello, world!\"], {type: \"text\u002Fplain;charset=utf-8\"});\nFileSaver.saveAs(blob, \"hello world.txt\");\n```\n\n### Saving text\n\n```js\nvar blob = new Blob([\"Hello, world!\"], {type: \"text\u002Fplain;charset=utf-8\"});\nFileSaver.saveAs(blob, \"hello world.txt\");\n```\n\n### Saving URLs\n\n```js\nFileSaver.saveAs(\"https:\u002F\u002Fhttpbin.org\u002Fimage\", \"image.jpg\");\n```\nUsing URLs within the same origin will just use `a[download]`.\nOtherwise, it will first check if it supports cors header with a synchronous head request.\nIf it does, it will download the data and save using blob URLs.\nIf not, it will try to download it using `a[download]`.\n\nThe standard W3C File API [`Blob`][4] interface is not available in all browsers.\n[Blob.js][5] is a cross-browser `Blob` implementation that solves this.\n\n### Saving a canvas\n```js\nvar canvas = document.getElementById(\"my-canvas\");\ncanvas.toBlob(function(blob) {\n    saveAs(blob, \"pretty image.png\");\n});\n```\n\nNote: The standard HTML5 `canvas.toBlob()` method is not available in all browsers.\n[canvas-toBlob.js][6] is a cross-browser `canvas.toBlob()` that polyfills this.\n\n### Saving File\n\nYou can save a File constructor without specifying a filename. If the\nfile itself already contains a name, there is a hand full of ways to get a file\ninstance (from storage, file input, new constructor, clipboard event).\nIf you still want to change the name, then you can change it in the 2nd argument.\n\n```js\n\u002F\u002F Note: Ie and Edge don't support the new File constructor,\n\u002F\u002F so it's better to construct blobs and use saveAs(blob, filename)\nvar file = new File([\"Hello, world!\"], \"hello world.txt\", {type: \"text\u002Fplain;charset=utf-8\"});\nFileSaver.saveAs(file);\n```\n\n\n\n![Tracking image](https:\u002F\u002Fin.getclicky.com\u002F212712ns.gif)\n\n  [1]: http:\u002F\u002Feligrey.com\u002Fdemos\u002FFileSaver.js\u002F\n  [2]: https:\u002F\u002Fgithub.com\u002Feligrey\u002Fcanvas-toBlob.js\n  [3]: https:\u002F\u002Fbugs.chromium.org\u002Fp\u002Fchromium\u002Fissues\u002Fdetail?id=375297#c107\n  [4]: https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FDOM\u002FBlob\n  [5]: https:\u002F\u002Fgithub.com\u002Feligrey\u002FBlob.js\n  [6]: https:\u002F\u002Fgithub.com\u002Feligrey\u002Fcanvas-toBlob.js\n  [7]: https:\u002F\u002Fgithub.com\u002Fjimmywarting\u002FStreamSaver.js\n  [8]: https:\u002F\u002Fgithub.com\u002Feligrey\u002FFileSaver.js\u002Fwiki\u002FSaving-a-remote-file#using-http-header\n\nInstallation\n------------------\n\n```bash\n# Basic Node.JS installation\nnpm install file-saver --save\nbower install file-saver\n```\n\nAdditionally, TypeScript definitions can be installed via:\n\n```bash\n# Additional typescript definitions\nnpm install @types\u002Ffile-saver --save-dev\n```\n","FileSaver.js 是一个用于在客户端保存文件的 HTML5 saveAs() 实现。它支持将生成的文件直接保存到用户的本地设备，适用于需要在浏览器端生成并保存文件的Web应用。该库利用了Blob对象来创建文件，并且不需要额外的依赖即可工作于现代浏览器中，包括Firefox、Chrome、Edge等。对于需要处理大文件或内存受限的情况，推荐使用更高级的StreamSaver.js。FileSaver.js特别适合那些需要跨浏览器兼容性但又不希望服务器直接参与文件传输的应用场景。",2,"2026-06-11 02:52:29","top_language"]