docs for using url
This commit is contained in:
@@ -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.
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
"ignore": [
|
||||
"*",
|
||||
"!FileSaver.*js",
|
||||
"!FileSaver.*map",
|
||||
"!LICENSE.md"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user