I'm trying to send a file to an SMB server, using some code:
from smb.SMBConnection import SMBConnection
file_obj = open('VA.jpg', 'rb')
connection = SMBConnection(username = 'Admin',
password = 'Pa$$w0rd',
my_name = '',
remote_name = 'ARM4',
domain = 'WORKGROUP',
use_ntlm_v2=True)
connection.connect(ip='192.168.34.105')
connection.storeFile(service_name='Share',
path='\\192.168.34.105\Share',
file_obj=file_obj)
connection.close()
But when I run it I get an error:
Exception has occurred: OperationFailure
Failed to store 192.168.34.105\Share on Share: Unable to open file
==================== SMB Message 0 ====================
SMB Header:
-----------
Command: 0x03 (SMB2_COM_TREE_CONNECT)
Status: 0x00000000
Flags: 0x00
PID: 5628
MID: 3
TID: 0
Data: 52 bytes
b'0900000048002c005c005c00330034004f00540044002d00410052004d0034002d004c00450042005c0053006800610072006500'
SMB Data Packet (hex):
----------------------
b'fe534d4240000000000000000300000000000000000000000300000000000000fc150000000000001500000400a00000000000000000000000000000000
and so on, SMB Message 1
... SMB Message 3
there is an error in the code in the line:
line 14, in <module>
connection.storeFile(service_name='Share',
smb.smb_structs.OperationFailure: Failed to store 192.168.34.105\Share on Share: Unable to open file
Could you tell me please what I'm doing wrong? How to correctly specify parameters?
figured it out.
it is necessary to specify the name of the file that will be on the server in the
path
parameter whereconnection.storeFile
, i.e. like this: