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

Why there is a problem with file saving in FLet? #4605

Open
1 task done
LopoDistrict opened this issue Dec 21, 2024 · 1 comment
Open
1 task done

Why there is a problem with file saving in FLet? #4605

LopoDistrict opened this issue Dec 21, 2024 · 1 comment

Comments

@LopoDistrict
Copy link

Duplicate Check

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

@LopoDistrict
Copy link
Author

I fixed my error something with the app structures that is different between Windows 11 and Android. I don't know how to dlete this issue because its pointless so if anyone could delete it or tell me how to remove 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

1 participant