Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to send/receive a file from samba shared folder?

How to send/receive a file from samba shared folder?

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 4 Posters 2.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • MarKSM Offline
    MarKSM Offline
    MarKS
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      MarKSM 1 Reply Last reply
      2
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        1
        • SGaistS SGaist

          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.

          MarKSM Offline
          MarKSM Offline
          MarKS
          wrote on last edited by MarKS
          #4

          @SGaist 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?

          Kent-DorfmanK 1 Reply Last reply
          0
          • MarKSM MarKS

            @SGaist 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?

            Kent-DorfmanK Offline
            Kent-DorfmanK Offline
            Kent-Dorfman
            wrote on last edited by
            #5

            @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

            MarKSM 1 Reply Last reply
            0
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi
              Windows understand SMB so if the share is set up correctly

              You can use the
              copy command

              copy 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 password

              Do 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.

              MarKSM 1 Reply Last reply
              3
              • Kent-DorfmanK Kent-Dorfman

                @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

                MarKSM Offline
                MarKSM Offline
                MarKS
                wrote on last edited by
                #7

                @Kent-Dorfman My bad. I have been through those links but it is already 7 yrs old. Thought there might be improvements to it.

                1 Reply Last reply
                0
                • mrjjM mrjj

                  Hi
                  Windows understand SMB so if the share is set up correctly

                  You can use the
                  copy command

                  copy 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 password

                  Do 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.

                  MarKSM Offline
                  MarKSM Offline
                  MarKS
                  wrote on last edited by
                  #8

                  @mrjj This is very resourceful and informative. I got my answer. Thanks!

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved