Skip to content

Commit

Permalink
Minor update in README
Browse files Browse the repository at this point in the history
  • Loading branch information
Amphiluke committed Dec 22, 2023
1 parent 58b6db8 commit ece2cc1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,24 @@ To construct a Blob representation for a file contents, either use the [`Blob` c
let blob = new Blob(["file contents"], {type: "text/plain"});
let fileName = "my-file.txt";
cordova.plugins.saveDialog.saveFile(blob, fileName).then(uri => {
console.info("The file has been successfully saved to", uri);
console.info("The file has been successfully saved to", uri);
}).catch(reason => {
console.warn(reason);
console.warn(reason);
});
```

or apply other methods of blob generation (such as [`Response.blob()`](https://developer.mozilla.org/en-US/docs/Web/API/Response/blob) for a network-fetched content):

```javascript
try {
let response = await fetch(`https://avatars.dicebear.com/api/avataaars/${Math.random()}.svg`);
let blob = await response.blob();
let uri = await cordova.plugins.saveDialog.saveFile(blob, "random-avatar.svg");
console.info("The file has been successfully saved to", uri);
let response = await fetch("https://httpbin.org/image/jpeg", {
headers: {Accept: "image/jpeg"}
});
let blob = await response.blob();
let uri = await cordova.plugins.saveDialog.saveFile(blob, "jackal.jpeg");
console.info("The file has been successfully saved to", uri);
} catch (e) {
console.error(e);
console.error(e);
}
```

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-save-dialog",
"version": "2.0.0",
"version": "2.0.1",
"description": "Cordova plugin for opening the native Save dialog and storing a file in the user-selected location",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="cordova-plugin-save-dialog" version="2.0.0">
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="cordova-plugin-save-dialog" version="2.0.1">
<name>Save Dialog</name>
<description>Cordova plugin for opening the native Save dialog and storing a file in the user-selected location</description>
<license>MIT</license>
Expand Down

0 comments on commit ece2cc1

Please sign in to comment.