Created
January 8, 2021 03:15
-
-
Save bhaskar-nair2/61eaacd610735b24cca88c4f1e52cf84 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get File | |
const getFileBtn = document.getElementById("fs-get") | |
getFileBtn.onclick = async () => { | |
const [handle] = await window.showOpenFilePicker(); | |
const file = await handle.getFile(); | |
console.log(file) | |
} | |
// Save File | |
const saveFileBtn = document.getElementById("fs-save") | |
saveFileBtn.onclick = async () => { | |
const textFile = new File(["Hello World"], hello.text, { | |
type: "text/plain" | |
}) | |
const handle = window.showSaveFilePicker(); | |
const writeable = await handle.createWritable(); | |
await writeable.write(textFile); | |
await writeable.close() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment