Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow us to directly construct the FileSystemFileHandle if we already know the path #301

Closed
swyxio opened this issue Jun 4, 2021 · 2 comments

Comments

@swyxio
Copy link

swyxio commented Jun 4, 2021

hi folks thanks for working on this great API!

right now the only way to get a FileSystemFileHandle is by using a showOpenFilePicker. however we may ALREADY know the filepath and just want to read and write to it without opening a picker. as far as I can tell there's no way to do that.

what i'd ideally want is something like:

let fileHandle = new FileSystemFileHandle(knownFilePath)

// // the below operations would Just Work™
// read
const fileData = await fileHandle.getFile();    
let contents = await fileData.text()

// write
const writable = await fileHandle.createWritable();
await writable.write(contents + 'epsilon');
await writable.close();

use case: https://github.com/sw-yx/svelte-filesystem-demo

@mkruisselbrink
Copy link
Contributor

Allowing websites to request access to specific file paths is much more dangerous than only allowing websites access to file paths users explicitly picked, as such we're not currently planning to implement a feature like this.

@jimmywarting
Copy link

jimmywarting commented Jun 7, 2021

i think he kind of want a cd or recursive mkdir method on the FileSystemDirectoryHandle itself

Say that you already have access to the root directory and you have saved it into IndexeDB and you know for sure that you will also have access to all the subfolder of something that you have already given permission to.

So it would be something like

const handle = await showDirectoryPicker()
handle.getDirectoryHandle('./some/deep/subpath/within/the/handle')

I guess it would not be anything harmful about that. It's possible to create like a recursive function of it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants