Example of pysmb

前端 未结 3 702
醉梦人生
醉梦人生 2021-02-13 23:57

Could you give me an example of using pysmb library to connect to some samba server? I\'ve read there\'s class smb.SMBConnection.SMBConnection(username, password, my_name, remot

3条回答
  •  被撕碎了的回忆
    2021-02-14 00:08

    For example you want to store a file via pysmb same as this:

    from smb.SMBConnection import SMBConnection
    
    file_obj = open('image.png', 'rb')
    
    connection = SMBConnection(username=username,
                               password=password,
                               remote_name=remote_name,  # It's net bios  name
                               domain=domain,
                               use_ntlm_v2=True)
    
    connection.connect(ip=host)  # The IP of file server
    
    connection.storeFile(service_name=service_name,  # It's the name of shared folder
                         path=path,
                         file_obj=file_obj)
    connection.close()
    
    
    

提交回复
热议问题