" /> " /> "/>

file selector does not function as expected

79 Views Asked by At

I have an upload "file_selector" in my markdown

<|{file_path}|file_selector|label=Select file|extensions=.csv,.xlsx|drop_message=Drop here to upload|>
<|Upload|button|on_action=upload_data|>

and have initialized the file path to none, when I try to print the path in upload_data I get a warning and an error path.

file_path = None

def upload_data(state) -> None:
     print(state.file_path)

the warning I am getting is as follows:

TaipyGuiWarning: :
Can't find matching variable for tpec_TpExPr_file_path_TPMDL_4 on context: __main__

and file path being:

C:\xxx\Temp\hemisphere_STEP.10.stp

where the real path is "C:\xxx\Temp\hemisphere_STEP.stp". when I refresh the page and upload the file again the number in the path increments and the file path becomes "C:\xxx\Temp\hemisphere_STEP.11.stp" This number in the path keeps incrementing to 12,13,14. irrespective of if I close the browser and start the application again.

Also, can I avoid showing the automatic message "hemisphere_STEP.stp Uploaded Successfully" once I drop the file? in the notification, it shows the file name correctly.

1

There are 1 best solutions below

2
Alexandre Sajus On

This seems to be normal behavior: when using the file_selector, Taipy copies the file locally to Temp and uses the Temp path. When you re-upload the same file, it can create multiple copies.

While this system does not seem necessary locally, it is when running on a server. When on a server, the server will have to copy to its "Temp" folder a copy of the user's file and access the server copy of the file as it does not have access to the original file on the user's machine.

The warning you are getting seems to be from another part of your code, as I do not get it when reproducing the issue.

Unfortunately, there is no way to remove the upload notification currently.

Do not hesitate to ask if you need more help or are unsatisfied with how this works. I can create an issue with R&D if needed.

Cheers, Alex