Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fsmount problems: py vs mpy, directory location, etc #2338

Open
@Neon22

Description

@Neon22

Checklist

  • I added a descriptive title
  • I searched for other issues and couldn't find a solution or duplication
  • I already searched in Google and didn't find any good information or help

What happened?

I am trying to use the fs.mount capability.
Tried in 2025.3.1 and in https://cdn.jsdelivr.net/npm/@pyscript/[email protected]/dist/core.js

I have mpy and py minimal examples here:

I get different errors for py, mpy and for calling from __main__ and for event driven.
Its also possible I have a security setting in chrome which prevents this from working at all.

Questions:

  1. If Chrome is blocking the request due to a security setting? which setting will it be (I will need to tell users how to enable the capability if this happens to them).
  2. I am assuming its not implemented in mpy yet.

So:
the pyodide example contains two calls. One from main and one from a user click event. The one from main does popup a dialog. The other gets stuck. What is the solution ?

  1. When its working - How do I find the files and operate on them ?
  2. I assume we can't know the name of the directory the user selected. Is that true?
  3. Is there a way to call Sync when the user closes the tab, or navigates away ?
    • Or is best approach to set a timer and sync repeatedly.

Errors for mpy, py are in attached console info

What browsers are you seeing the problem on? (if applicable)

Chrome

Console info

In Mpy version:
# if using event `click` to fire then get this error:

Uncaught (in promise) Error: storage permissions not granted
    at Object.Nr [as getFileSystemDirectoryHandle] (fs.js:52:42)


# if using the await in `__main__` then get this error:
 Uncaught (in promise) Error: storage permissions not granted
 at HTMLButtonElement.<anonymous> (fs.js:73:20)
# However I did click on Authorize but the dialog did not close, or offer feedback


In Pyodide I get these two errors:
# if using event `click` to fire then get this error:

fs.js:44 Failed to execute 'showDirectoryPicker' on 'Window': 
 Cross origin sub frames aren't allowed to show a file picker.


# if using the await in `__main__` then get this error:

File "/home/pyodide/pyscript/fs.py", line 14, in mount
    else:B=await A.getFileSystemDirectoryHandle(H(F));await A.idb.set(C,B)

However I did click on Authorize but the dialog did not close, or offer feedback

Additional Context

What I am trying to do is:

  • determine if the browser offers the capability of mounting a user directory
  • Check local storage to see if the user has selected a file before or not (this code is not in the examples)
  • Prompt user to select the (lets call it a home directory)
  • mount that home directory in /local
  • read and write to those files from my app.
  • occasionally call sync to push them back to the user's local machine
  • IF there is no fs.mount capability - do something else...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions