I am trying to create a simple script to upload a file to a windows share. SO far I get connection, and the script even creates an empty file perfectly fine. But the data doesn't quite make it.
The bellow code seems to establish the connection ok and allows me to list shares etc. when writing the empty file is left behind just fine.
import smb
from smb.SMBConnection import SMBConnection
share_name = "sharesRus"
user_name = "blanked_user"
password = "blanked_password"
local_machine_name = "Server6"
server_machine_name = "server.domains.lastbit.com"
server_IP = "10.100.100.45"
# create and establish connection
conn = SMBConnection(user_name, password, local_machine_name, server_machine_name, use_ntlm_v2 = True, is_direct_tcp = True)
connected = conn.connect(server_IP, 445)
print(connected)
filename = 'D:\\Users\\Username\\Desktop\\data.csv'
with open(filename, 'rb') as in_file:
conn.storeFile(share_name, '/TestData4.csv', in_file)
conn.close()
Error I get
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host