File Transfer¶
Connector can do file exchange in a very easy way. But can only exchange files between server and client. Client and client cannot exchange file directly, but they can do it through server. You can use following functions to get/put files/folders between client and server(where client on client side means client object and on server side means client peer).
client.get_file(src_file_path, dest_file_path = None, block = True): Get file from remote computer.src_file_path: Remote file path you need to get from remote computer.dest_file_path: Local file path you need to put the file at. If it’sNone, it will put file at current working directory.block: If it’sTrue, it will block the process until file transfer finished. Otherwise this method will immediately return aFutureobject which you can calldonemethod on it to check if transfer is finished. To see more usage of aFutureobject, please refer to User Functions Reference
client.put_file(src_file_path, dest_file_path = None, block = True): Put local file to remote computer.src_file_path: Local file path you need to put to remote computer.dest_file_path: Remote computer file path which you need to put file at. If it’sNone, it will put file at remote script working directory.block: If it’sTrue, it will block the process until file transfer finished. Otherwise this method will immediately return aFutureobject which you can calldonemethod on it to check if transfer is finished. To see more usage of aFutureobject, please refer to User Functions Reference
client.get_folder(src_folder_path, dest_folder_path = None, block = True): Get folder from remote computer. The usage is just likeget_file.client.put_folder(src_folder_path, dest_folder_path = None, block = True): Put local folder to remote computer. The usage is just likeput_file.server.put_file_to_all(src_file_path, dest_file_path): Put server computer’s filesrc_file_pathto all connected clients as pathdest_file_path.server.put_folder_to_all(src_folder_path, dest_folder_path): Put server computer’s foldersrc_folder_pathto all connected clients as pathdest_folder_path.