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

[Feature] Support permissions for chromium File System Access API #18267

Open
kepta opened this issue Oct 22, 2022 · 15 comments
Open

[Feature] Support permissions for chromium File System Access API #18267

kepta opened this issue Oct 22, 2022 · 15 comments

Comments

@kepta
Copy link

kepta commented Oct 22, 2022

I am the author of bangle-io - a library which allows taking note locally thanks to the File System Access API.

Currently Playwright doesn't support accepting permissions (see the screenshot) to view/edit a local file using the following api.

let dirHandle = await window.showDirectoryPicker();
const perms = await dirHandle.requestPermission(opts);

image

Do you think others might benefit from this as well?

This will benefit folks writing robust apps which provide local first support.

mgreminger added a commit to mgreminger/EngineeringPaper.xyz that referenced this issue Feb 6, 2023
Playwright does not currently support the File System Access API [Related Issue](microsoft/playwright#18267)
@lubobill1990
Copy link

I really need this in playwright!

@zalo
Copy link

zalo commented Apr 12, 2023

Likewise, I would benefit from this as well!

@sepehr500
Copy link

I would also love this feature. 🙏

@zalo
Copy link

zalo commented Apr 25, 2023

For intrepid future travelers, I bypassed this by evaling a function that returns a list of filenames and base64 encoded bytes from blobs.

In the browser page:

async function blobToBase64(blob) {
  return new Promise((resolve, _) => {
    let reader = new FileReader();
    reader.onloadend = () => resolve(reader.result.split(',')[1]);
    reader.readAsDataURL(blob);
  });
}

window.getFilesAsB64 = async function () {
  // Get a list of filenames and a list of blobs somehow
  let files = {};
  for (let i = 0; i < blobs.length; i++) {
    files[filenames[i]] = await blobToBase64(blobs[i]);
  }
  return files;
}

In the playwright-python app:

files = await page.evaluate("window.getFilesAsB64()")
for filename in files:
    with open("./"+filename, "wb") as binary_file:
        binary_file.write(base64.b64decode(files[filename]))

@Yesterday17
Copy link

For intrepid future travelers, I bypassed this by evaling a function that returns a list of filenames and base64 encoded bytes from blobs.

It's not a workaround for this issue, but a workaround for file writing. In fact, we want permission support for FileSystem Access API just because we are using this API and want to test programs relying on this. If we just want to read/write files, we can use workarounds instead.

@bildungsroman
Copy link

This would really come in handy for my team as well. Our app relies heavily on the FSA API

@darkvertex
Copy link

I need this too! 🙏

I bet the Microsoft devs behind https://vscode.dev (which uses the Filesystem API) would appreciate it also.

@hevilhuy
Copy link

I need this feature

@alvaromartmart
Copy link
Contributor

+1 would be awesome if Playwright supported these APIs

@dpmillerau
Copy link

also need

@GamerGirlandCo
Copy link

how long do you intend to "collect feedback" for..?

@huyz
Copy link

huyz commented Oct 24, 2024

how long do you intend to "collect feedback" for..?

Why is it that github.com is filling up with more and more people complaining about how long tickets have been open for?
The sense of entitlement is simply embarrassing. I guess we should go back to a world of only paid, proprietary software?

@GamerGirlandCo

This comment has been minimized.

@jibow
Copy link

jibow commented Oct 28, 2024

Are there any news if or when this could be supported? I'm also eagerly waiting for playwright to support this.

@Amatewasu
Copy link

For those having the issue, I have implemented a workaround on my app. Instead of providing the FileSystemHandle using showDirectoryPicker, I load a zip (with an input type file) of the test folder that I unzip, and I load all the files into the navigator.storage.getDirectory and then I provide this FileSystemHandle to the rest of the code. It works greatly.

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

No branches or pull requests