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
+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.