Edwinexd / Edwinexd/sql-validator

Allow open & save to file (window.showOpenFilePicker)

Aperta
#13 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
enhancement
Lingua principale
TypeScript
Stelle
4
Fork
2
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

There is a webapi in development that could be used to allow users to open/create a save file once and then repeatedly save to the same file without creating a bunch of dumps in the users download folder
https://developer.mozilla.org/en-US/docs/Web/API/Window/showOpenFilePicker#browser_compatibility

Example generated by Chatgpt:
```js
// Open file
async function openFile() {
const [fileHandle] = await window.showOpenFilePicker();
const file = await fileHandle.getFile();
const contents = await file.text();
console.log(contents); // Load file contents
return fileHandle; // Return handle for saving
}

// Save file
async function saveFile(fileHandle, data) {
const writableStream = await fileHandle.createWritable();
await writableStream.write(data); // Write new content
await writableStream.close();
}
```

Edit: might be more readily available then I initially thought https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.