flet
flet copied to clipboard
Why there is a problem with file saving in FLet?
Duplicate Check
- [X] I have searched the opened issues and there are no duplicates
Describe the bug
In order to manage all users file in my flet app I use a filemanager file and request the permission for MANAGE_EXTERNAL_STORAGE in Flet but the application still have a problem.
I tried to grant STORAGE also but I don't know why it get deny every time, I also added
[tool.flet.android.permission]
"android.permission.MANAGE_EXTERNAL_STORAGE" = true
"android.permission.STORAGE" = true
in pyproject.toml
Code sample
filemanager.py
def get_external_storage_directory(self) -> Path:
storage_dir = os.getenv("EXTERNAL_STORAGE") or os.getenv("HOME")
if storage_dir is None:
# Fallback to current directory if no suitable environment variable is found.
storage_dir = "."
return Path(storage_dir)
def get_file_path(self, filename: str) -> Path:
"""Returns the full path of a file."""
return self.base_path / ("src/" + filename)
#other function write/read etc...
main.py
ph = ft.PermissionHandler()
page.overlay.append(ph)
page.update()
permission_container = ft.Column()
def request_permissions(e):
manage_result = ph.request_permission(ft.PermissionType.MANAGE_EXTERNAL_STORAGE)
storage_result = ph.request_permission(ft.PermissionType.STORAGE)
if manage_result and storage_result:
#permission_container.controls.clear()
page.add(ft.Text(f"Requested MANAGE_EXTERNAL_STORAGE: {manage_result}"))
page.add(ft.Text(f"Requested STORAGE: {storage_result}"))
page.update()
else:
page.add(ft.Text("Failed to grant required permissions."))
To reproduce
s
Expected behavior
No response
Screenshots / Videos
Captures
[Upload media here]
Operating System
Windows
Operating system details
Windows 11
Flet version
0.25.2
Regression
I'm not sure / I don't know
Suggestions
No response
Logs
No response
Additional details
No response