Repository navigation
File Transfer
wapyt.filetransfer is not a widget: it is a set of functions for native file
pickers and streaming transfers. Bytes never cross into Python. A download is
piped from the network straight into a file handle, and an upload goes from a
File to XMLHttpRequest. Python decides what to transfer and shows progress.
from wapyt import filetransfer
async def on_download_click(_event):
chosen = await filetransfer.pick_save_file("app.log") # FIRST, while the click still counts
if not chosen.ok:
return # cancelled is not an error
result = await filetransfer.save_file(chosen.id, "/files/7/download?path=app.log",
on_progress=lambda seen, total: show(seen, total))
filetransfer.release(chosen.id)Every picker needs transient user activation, and the first await
consumes it. Call pick_save_file, pick_folder or pick_files as the very
first thing in the click handler, before any BFF call, or the browser raises
SecurityError.
The pickers are Chromium-only. Check capabilities().pickers and tell the user
when they're missing, rather than silently falling back to
download_via_anchor(), which saves to the downloads folder with no progress.
| Function | |
|---|---|
capabilities() |
Capabilities(save_file, directory, open_file, secure_context); .pickers
|
pick_save_file(name) · pick_folder() · pick_files(multiple, directory)
|
→ TransferResult
|
save_file(handle_id, url, transfer_id, on_progress) |
Stream a URL into a picked file |
save_into(folder_id, relative_path, url, ...) |
Into a picked folder, creating subfolders |
exists(folder_id, name) |
Check before save_into overwrites |
upload(url, file_id, fields, transfer_id, on_progress) |
Multipart POST with progress; pyTincture's CSRF token is attached, including under a custom cookie_namespace
|
adopt(file) |
Register a dropped File (see DataTable on_drop) for upload
|
resume(transfer_id) |
Continue a download that lost its connection (Range + If-Range) |
cancel(transfer_id) · release(handle_id) · release_all()
|
Control and cleanup |
download_via_anchor(url, name) |
Fallback without pickers |
TransferResult(ok, cancelled, error, id, name, bytes, via_anchor, files, resumable, retries, restarted):
files holds PickedFile(id, name, size, path) for uploads, where path is
folder-relative after a directory pick.
wapyt is MIT-licensed · Repository · pyTincture · Issues
Getting started
Widgets
- Layout and MainWindow
- Tree
- DataTable
- Form
- ModalWindow
- Window
- TabWidget
- Toolbar
- Sidebar
- Chat
- Terminal
- CardPanel
- ResourceBoard
- File Transfer
- Message
- ContextMenu
- MenuBar
- Listbox
- Kanban
- ProgressBar
- Pagination
- Popup and tooltips
- Chart
- Scheduler
- MediaPlayer
Guides
Planning
Contributing