Open martinmarsicano opened 1 year ago
Certainly looks good, and we need to make sure that we have support for a wide range of browsers
Hey @jgadsden, It seems quite interesting. I have a code snippet in JS for do same. We can implement it !!
// Request file system access
async function requestFileSystemAccess() {
try {
const [fileHandle] = await window.showOpenFilePicker();
const file = await fileHandle.getFile();
// Read file contents
const fileContents = await file.text();
console.log('File contents:', fileContents);
// Write to a file
const writableFile = await fileHandle.createWritable();
await writableFile.write('New content');
await writableFile.close();
console.log('File updated successfully!');
} catch (error) {
console.error('An error occurred:', error);
}
}
// Call the function to request file system access
requestFileSystemAccess();
Thanks @professorabhay this is useful for sure We need to make sure any changes work for a wide range of browsers as well Chrome / Chromium) and that the desktop version works OK as well
Yes @jgadsden, As much I know that File System Access is still missing from some browsers. We need to make some checks while implementing it.
showOpenFilePicker
is already used, so showSaveFilePicker
should also be used on Save
Describe what problem your feature request solves The actual way of handling local threat models could generate a lot of files because a new file is generated each time a user saves the working threat model.
Describe the solution you'd like On chromium based browsers the new File System Access API should be used (it's the one used in https://vscode.dev/)
Additional context Blog presenting the API: https://developer.chrome.com/articles/file-system-access/