This commit is contained in:
Jimmy Wärting
2016-05-31 09:30:32 +02:00
parent bc0ba24aaa
commit 3eeddf1145
4 changed files with 16 additions and 4 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
/* FileSaver.js
* A saveAs() FileSaver implementation.
* 1.2.2
* 1.3.0
*
* By Eli Grey, http://eligrey.com
* License: MIT
+13 -1
View File
@@ -54,7 +54,7 @@ Syntax
------
```js
FileSaver saveAs(Blob data, DOMString filename, optional Boolean disableAutoBOM)
FileSaver saveAs(Blob/File data, optional DOMString filename, optional Boolean disableAutoBOM)
```
Pass `true` for `disableAutoBOM` if you don't want FileSaver.js to automatically provide Unicode text encoding hints (see: [byte order mark](https://en.wikipedia.org/wiki/Byte_order_mark)).
@@ -82,6 +82,18 @@ canvas.toBlob(function(blob) {
});
```
### Saving File
You can save a File constructor without specifying a filename. The
File itself already contains a name, There is a hand full of ways to get a file
instance (from storage, file input, new constructor)
But if you still want to change the name, then you can change it in the 2nd argument
```js
var file = new File(["Hello, world!"], "hello world.txt", {type: "text/plain;charset=utf-8"});
saveAs(file);
```
Note: The standard HTML5 `canvas.toBlob()` method is not available in all browsers.
[canvas-toBlob.js][6] is a cross-browser `canvas.toBlob()` that polyfills this.
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "file-saver",
"main": "FileSaver.js",
"version": "1.2.2",
"version": "1.3.0",
"homepage": "https://github.com/eligrey/FileSaver.js",
"authors": [
"Eli Grey <me@eligrey.com>"
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "file-saver",
"version": "1.2.2",
"version": "1.3.0",
"description": "An HTML5 saveAs() FileSaver implementation",
"main": "FileSaver.js",
"scripts": {