flet icon indicating copy to clipboard operation
flet copied to clipboard

FilePicker Not Working Properly In Android and Web

Open Siva-Rajan-R opened this issue 1 year ago • 2 comments

Duplicate Check

  • [X] I have searched the opened issues and there are no duplicates

Describe the bug

When I Try To Get A File In Android And Web It Shows An Error. But Windows It Works Fine,

For Android ,It Show There Is No File Or Directory ;

Future exception was never retrieved

future: <Future finished exception=FileNotFoundError(2, 'No such file or directory')> Traceback (most recent call last): File "C:\Users\aarthi\AppData\Local\Programs\Python\Python312\Lib\concurrent\futures\thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\aarthi\AppData\Local\Programs\Python\Python312\Lib\site-packages\flet_core\page.py", line 944, in wrapper handler(*args) File "C:\python_project\Sell_Any_Flet_App\main.py", line 2779, in pick_file_chat with open(path,'rb') as fr: ^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: '/data/user/0/com.appveyor.flet/cache/file_picker/1728736726850/1000008325.jpg'

For Web , If I Select A FIle It Only Give The File Name , The File Path Is Set TO Be None ;

Future exception was never retrieved

future: <Future finished exception=TypeError('expected str, bytes or os.PathLike object, not NoneType')> Traceback (most recent call last): File "C:\Users\aarthi\AppData\Local\Programs\Python\Python312\Lib\concurrent\futures\thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\aarthi\AppData\Local\Programs\Python\Python312\Lib\site-packages\flet_core\page.py", line 944, in wrapper handler(*args) File "C:\python_project\Sell_Any_Flet_App\main.py", line 2779, in pick_file_chat with open(path,'rb') as fr: ^^^^^^^^^^^^^^^ TypeError: expected str, bytes or os.PathLike object, not NoneType

Code sample

Code

``...`


</details>


### To reproduce

...

### Expected behavior

_No response_

### Screenshots / Videos

<details open>
<summary>Captures</summary>

[Upload media here]

</details>


### Operating System

Windows

### Operating system details

windows 11

### Flet version

0.24.1

### Regression

I'm not sure / I don't know

### Suggestions

_No response_

### Logs

<details open><summary>Logs</summary>

```console
[Paste your logs here]

Additional details

No response

Siva-Rajan-R avatar Oct 12 '24 12:10 Siva-Rajan-R

Can you please re-format your issue and provide some reproducible code?

OwenMcDonnell avatar Oct 15 '24 20:10 OwenMcDonnell

Works for me on android, google tv streamer has issues however.

syleishere avatar Oct 25 '24 23:10 syleishere

Can you please try the latest pre-release and let know if the issue still happens?

ndonkoHenri avatar Dec 08 '25 00:12 ndonkoHenri

I gave it a try using the latest pre-release and it works as expected.

Code

import flet as ft


def main(page: ft.Page):
    async def handle_pick_files(e: ft.Event[ft.Button]):
        files = await ft.FilePicker().pick_files(allow_multiple=True)
        selected_files.value = (
            ", ".join(map(lambda f: f.name, files)) if files else "Cancelled!"
        )

    async def handle_get_directory_path(e: ft.Event[ft.Button]):
        directory_path.value = await ft.FilePicker().get_directory_path()

    page.add(
        ft.SafeArea(
            content=ft.Column(
                controls=[
                    ft.Row(
                        controls=[
                            ft.Button(
                                content="Pick files",
                                icon=ft.Icons.UPLOAD_FILE,
                                on_click=handle_pick_files,
                            ),
                            selected_files := ft.Text(),
                        ]
                    ),
                    ft.Row(
                        controls=[
                            ft.Button(
                                content="Open directory",
                                icon=ft.Icons.FOLDER_OPEN,
                                on_click=handle_get_directory_path,
                                disabled=page.web,  # disable this button in web mode
                            ),
                            directory_path := ft.Text(),
                        ]
                    ),
                ]
            )
        )
    )


ft.run(main)
Image

Let know if you face issues.

ndonkoHenri avatar Dec 12 '25 22:12 ndonkoHenri