Browse Source

add file-saver as backup

pull/157/head
Phillip 1 year ago
parent
commit
2a4866a679
  1. 36
      qortal-ui-plugins/plugins/core/qdn/browser/browser.src.js

36
qortal-ui-plugins/plugins/core/qdn/browser/browser.src.js

@ -11,7 +11,7 @@ import {
registerTranslateConfig({ registerTranslateConfig({
loader: (lang) => fetch(`/language/${lang}.json`).then((res) => res.json()), loader: (lang) => fetch(`/language/${lang}.json`).then((res) => res.json()),
}); });
import FileSaver from 'file-saver'
import * as actions from '../../components/qdn-action-types'; import * as actions from '../../components/qdn-action-types';
import '@material/mwc-button'; import '@material/mwc-button';
import '@material/mwc-icon'; import '@material/mwc-icon';
@ -1454,23 +1454,29 @@ class WebBrowser extends LitElement {
} }
} }
} }
const fileHandle = await self.showSaveFilePicker({
suggestedName: filename,
types: [
{
description: mimeType,
...fileHandleOptions
},
]
try {
const fileHandle = await self.showSaveFilePicker({
suggestedName: filename,
types: [
{
description: mimeType,
...fileHandleOptions
},
]
})
const writeFile = async (fileHandle, contents) => { })
const writable = await fileHandle.createWritable() const writeFile = async (fileHandle, contents) => {
await writable.write(contents) const writable = await fileHandle.createWritable()
await writable.close() await writable.write(contents)
await writable.close()
}
writeFile(fileHandle, blob).then(() => console.log("FILE SAVED"))
} catch (error) {
FileSaver.saveAs(blob, filename)
} }
writeFile(fileHandle, blob).then(() => console.log("FILE SAVED"))
response = JSON.stringify(true); response = JSON.stringify(true);
} catch (error) { } catch (error) {
const obj = {}; const obj = {};

Loading…
Cancel
Save