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 access the data received from FTP server?
QtWS25 Last Chance

How to access the data received from FTP server?

Scheduled Pinned Locked Moved Solved General and Desktop
qt creator
5 Posts 3 Posters 761 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.
  • K Offline
    K Offline
    kayakaan02
    wrote on 6 Dec 2022, 14:48 last edited by
    #1

    Hi, I've been using this(https://doc.qt.io/qt-6/qtscxml-ftpclient-example.html) ftp client to receive data from ftp server and it's working as intended.

    It displays the text inside the txt file in application output.

    But my question here is how can I access it? Where is it stored? I want to write it to some other file.

    Actually I want to get an xml file from ftp client and save it to my computer that's my purpose.

    Thanks in advance.

    J 1 Reply Last reply 6 Dec 2022, 14:54
    0
    • K kayakaan02
      6 Dec 2022, 14:48

      Hi, I've been using this(https://doc.qt.io/qt-6/qtscxml-ftpclient-example.html) ftp client to receive data from ftp server and it's working as intended.

      It displays the text inside the txt file in application output.

      But my question here is how can I access it? Where is it stored? I want to write it to some other file.

      Actually I want to get an xml file from ftp client and save it to my computer that's my purpose.

      Thanks in advance.

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 6 Dec 2022, 14:54 last edited by
      #2

      @kayakaan02 This is the place where data is received:

      QObject::connect(&dataChannel, &FtpDataChannel::dataReceived,
                           [](const QByteArray &data) {
              std::cout << data.constData() << std::flush;
          });
      

      Instead of simply printing it out you can accumulate the data returned by data.constData() in a member variable of type QByteArray. When the whole file was transferred you will have all the data in that member variable.
      Keep in mind that you should not do it this way if transferred file is big. In this case you can write what data.constData() returns into a file.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • K Offline
        K Offline
        kayakaan02
        wrote on 6 Dec 2022, 14:59 last edited by
        #3

        @jsulm Thanks, how did I not see that :D.

        Also I assume I cannot take this as a file and directly save it?

        I have to take what I have and save it into a file so that means more work?

        M J 2 Replies Last reply 6 Dec 2022, 15:21
        0
        • K kayakaan02
          6 Dec 2022, 14:59

          @jsulm Thanks, how did I not see that :D.

          Also I assume I cannot take this as a file and directly save it?

          I have to take what I have and save it into a file so that means more work?

          M Offline
          M Offline
          mpergand
          wrote on 6 Dec 2022, 15:21 last edited by
          #4

          @kayakaan02
          nothing prevents you from saving the bytearray directly to a file.

          1 Reply Last reply
          1
          • K kayakaan02
            6 Dec 2022, 14:59

            @jsulm Thanks, how did I not see that :D.

            Also I assume I cannot take this as a file and directly save it?

            I have to take what I have and save it into a file so that means more work?

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 7 Dec 2022, 07:07 last edited by
            #5

            @kayakaan02 said in How to access the data received from FTP server?:

            Also I assume I cannot take this as a file and directly save it?

            Of course you can. I also wrote it in my previous post...

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0

            1/5

            6 Dec 2022, 14:48

            • Login

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