-
Notifications
You must be signed in to change notification settings - Fork 2
Allow open & save to file (window.showOpenFilePicker) #13
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or request
Description
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:
// 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request