Discover peers and send files¶
Start the client on the same LAN as the LocalSend device. It discovers peers
while it is running; select a discovered Device
and use Client.send_files() to offer
files.
Python¶
This sends one file to the first peer discovered on the LAN:
from pathlib import Path
from time import sleep
from localsend import Client
with Client("My computer") as client:
while not client.devices:
sleep(1)
peer = client.devices[0]
uploaded = client.send_files(peer, [Path("report.pdf")])
print(uploaded)
The client waits until a peer appears in devices. Select a different entry
when more than one peer is available. Approve the file offer on the receiving
device. A receiver can accept only some files; send_files() returns only the
paths that it accepted and uploaded.
Pass pin="123456" to send_files() when the receiver requires a PIN. A
missing or invalid PIN raises PinRequiredError.
A rejected, cancelled, or already-busy transfer raises the corresponding public
upload error in the Public API.