How to send/receive a file from samba shared folder?
-
Consider me a newbie in Qt network programming. I have a simple UI where I select a file from my local PC and when I click on Send button I would like to send the file over to the samba shared folder.
I know the IP address and the port number I would like to connect to. But I am completely confused about what do I need to send the file. Do I need a Server and Client? Or QTcpSocket would be enough? No idea.
Any pointers to links or examples are appreciated.
-
Hi,
The usual way to do that is to mount the Samba share on your machine and use it like any other network drive. Then you can use QFile to copy the file over to it.
-
Hi
Just as a note.
There is also smbclient if on a Linux OS. it can copy files to a share.
https://www.linuxjournal.com/content/smbclient-security-windows-printing-and-file-transfer -
@MarKS said in How to send/receive a file from samba shared folder?:
I forgot to mention my app is supposed to work on Win 10. Do I still need to mount the samba share explicitly? Or does windows have native support to access share folders?
I don't believe Qt does, whether win10 can or not. If it's a file then transport it as a file to a mounted share. You probably don't want to write a Qt specific samba smb/cifs client class.
this <https://stackoverflow.com/questions/25298946/qt-is-there-a-class-for-shared-folders> may have useful information. First result in google search. LOL
-
Hi
Windows understand SMB so if the share is set up correctlyYou can use the
copy commandcopy file.txt \\ip_or_hostname\sharename
However, if the user needed for the shares, is different from the current login user in windows, it will
need to use runas which will not allow you to send a password as a parameter.In such cases,
you can use
net use x:\ip_or_hostname\sharename /user:username passwordDo note that the newest win 10 uses smb3 (protocol version) and will also use v2 on demand but for version smb1 it has to be enabled.
If a newer Linux box it uses smb3 pr default. only something to notice with an older Linux box. -
@Kent-Dorfman My bad. I have been through those links but it is already 7 yrs old. Thought there might be improvements to it.