-
Hi team, I am facing a problem when I was trying to download a text file using ui.link component. Sample test code parts are as below. Write the file and upload it to the server, users_list_file_path = os.path.join(q.app.users_list_dir, 'users_admins.txt')
if os.path.exists(users_list_file_path):
os.remove(users_list_file_path)
users_list_file = open(users_list_file_path, "a")
users_list_file.write(f"Users - {len(users)}\n\n")
write_export_users_file_content(users, users_list_file)
users_list_file.write(f"\nAdmins - {len(admins)}\n\n")
write_export_users_file_content(admins, users_list_file)
users_list_file.close()
(q.app.users_list_file_link,) = await q.site.upload([users_list_file_path]) Component file code line, ui.link(label="↗ Export Users", path=q.app.users_list_file_link,
button=True, download=True, target='_blank'), This opens the new browser tab with the content but not downloading. When I tested with the file extension .sig, .docx it downloaded the file with relevant extension. Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I haven't tested but maybe the browser tries to display |
Beta Was this translation helpful? Give feedback.
I haven't tested but maybe the browser tries to display
.txt
files and downloads the ones it doesn't support, like.docx
? What happens if you removetarget=_blank
?