docs for using url

This commit is contained in:
Jimmy Wärting
2018-09-26 12:00:35 +02:00
parent 37d757bbc6
commit 9e931126f5
2 changed files with 15 additions and 4 deletions
+12 -2
View File
@@ -64,10 +64,10 @@ import { saveAs } from 'file-saver/FileSaver';
```
```js
FileSaver saveAs(Blob/File data, optional DOMString filename, optional Boolean disableAutoBOM)
FileSaver saveAs(Blob/File/Url, optional DOMString filename, optional Boolean autoBOM)
```
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)).
Pass `true` for `autoBOM` 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)).
Examples
--------
@@ -86,6 +86,16 @@ var blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
FileSaver.saveAs(blob, "hello world.txt");
```
### Saving urls
```js
FileSaver.saveAs("https://httpbin.org/image", "image.jpg");
```
Using urls within the same origin will just use `a[download]`
Otherwise it will first check if it supports cors header with a synchronously head request
if it dose it will download the data and save it using blob urls
if not it will try to download it using `a[download]`
The standard W3C File API [`Blob`][4] interface is not available in all browsers.
[Blob.js][5] is a cross-browser `Blob` implementation that solves this.
+1
View File
@@ -16,6 +16,7 @@
"ignore": [
"*",
"!FileSaver.*js",
"!FileSaver.*map",
"!LICENSE.md"
]
}