Open
Description
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:
- pyodide: https://pyscript.com/@neon22/fsmount-min-pyodide/latest?files=main.py,index.html
- mpy: https://pyscript.com/@neon22/fsmount-min-mpy/latest?files=main.py,index.html
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:
- 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).
- 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 ?
- When its working - How do I find the files and operate on them ?
- I assume we can't know the name of the directory the user selected. Is that true?
- 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...