Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. QT6 QNetworkRequest and FTP
QtWS25 Last Chance

QT6 QNetworkRequest and FTP

Scheduled Pinned Locked Moved Unsolved Qt 6
qt6 ftpqnetworkrequest
22 Posts 10 Posters 7.0k 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.
  • M Offline
    M Offline
    MartinGU
    wrote on 28 Apr 2022, 14:06 last edited by
    #1

    Using Qt 5.15.2 the following code works, it connects to ftp server and puts file.
    In Qt 6.3.0 it does not work, Protocol "ftp" unknown.
    From same QtCreator, I just switch between Desktop Qt 6.15.2 GCC 64bit and Desktop Qt 6.3.0 GCC 64bit. Both opensource untouched installations on Linux Mint 20.3.

    bool DLG_MAIN::Put(QString sUrl, int iPort, QString sUser, QString sPass, QString sFile)
         {
         QNetworkAccessManager   nm;
         QEventLoop              loop;
    
    
         QUrl url("ftp://ftpserver.name_withhold.com" + sUrl);
         url.setUserName(sUser);
         url.setPassword(sPass);
         url.setPort(iPort);
    
         QFile data(sFile);
    
         QNetworkRequest *nrq = new QNetworkRequest(url);
    
         data.open(QIODevice::ReadOnly);
         auto nre = nm.put(*nrq, &data);
    
         QObject::connect(nre, SIGNAL(uploadProgress(qint64, qint64)),SLOT(putProgess(qint64, qint64)));
         QObject::connect(nre, SIGNAL(finished()), &loop, SLOT(quit()));
         loop.exec();
    
         data.close();
    
         if (nre->error() == QNetworkReply::NoError)
            return(true);
         else
            {
            int i = nre->error();
            QString strReply = (QString)nre->errorString();
    
            return(false);
            }
         }
    
    J 1 Reply Last reply 28 Apr 2022, 14:11
    0
    • M MartinGU
      28 Apr 2022, 14:06

      Using Qt 5.15.2 the following code works, it connects to ftp server and puts file.
      In Qt 6.3.0 it does not work, Protocol "ftp" unknown.
      From same QtCreator, I just switch between Desktop Qt 6.15.2 GCC 64bit and Desktop Qt 6.3.0 GCC 64bit. Both opensource untouched installations on Linux Mint 20.3.

      bool DLG_MAIN::Put(QString sUrl, int iPort, QString sUser, QString sPass, QString sFile)
           {
           QNetworkAccessManager   nm;
           QEventLoop              loop;
      
      
           QUrl url("ftp://ftpserver.name_withhold.com" + sUrl);
           url.setUserName(sUser);
           url.setPassword(sPass);
           url.setPort(iPort);
      
           QFile data(sFile);
      
           QNetworkRequest *nrq = new QNetworkRequest(url);
      
           data.open(QIODevice::ReadOnly);
           auto nre = nm.put(*nrq, &data);
      
           QObject::connect(nre, SIGNAL(uploadProgress(qint64, qint64)),SLOT(putProgess(qint64, qint64)));
           QObject::connect(nre, SIGNAL(finished()), &loop, SLOT(quit()));
           loop.exec();
      
           data.close();
      
           if (nre->error() == QNetworkReply::NoError)
              return(true);
           else
              {
              int i = nre->error();
              QString strReply = (QString)nre->errorString();
      
              return(false);
              }
           }
      
      J Offline
      J Offline
      JonB
      wrote on 28 Apr 2022, 14:11 last edited by JonB
      #2

      @MartinGU
      I don't know, but at Qt6 https://forum.qt.io/topic/125203/qt6-qnetworkaccessmanager-ftp-connection-and-manipulation seems to report the same issue (no resolution)?

      OK, it looks like you need to read QT6 Protocol "ftp" is unknown and https://www.qt.io/blog/qt-network-in-qt-6.

      1 Reply Last reply
      1
      • M Offline
        M Offline
        MartinGU
        wrote on 28 Apr 2022, 14:33 last edited by
        #3

        Thanks JonB!

        Yes, there is still no ftp-support in Qt6. It was said to be put in a separate module.
        That was said for more than a year ago...

        Found this in qt6-dev for 6.4 but if it will be released and when...
        https://doc-snapshots.qt.io/qt6-dev/qtscxml-ftpclient-example.html

        For us its to much stuff that is not yet in Qt6 or has changed to be much more complicated. Better to stay with QT5...

        1 Reply Last reply
        0
        • M Offline
          M Offline
          manordheim
          wrote on 12 May 2022, 12:01 last edited by
          #4

          Hello!

          Sorry! This is partially my fault :)
          The original plan for Qt 6 was to remove FTP from the default distribution given low usage and relevance in today's tech stacks. I, of course, knew that some people would still be interested in FTP, so the plan was to 'check the pulse' in 6.0/6.1 to see if anyone was actually missing the support. In the end there has been little-to-no demand to bring it back so it was never prioritized work internally.

          The reason for why the old support was removed that it was a somewhat brittle backend which was just based on the old QFtp code. It had limited support for normal FTP functionality today, and limited error handling. It was thus a cause for multiple bug-reports for 'simple' things with only complex/risky solutions.

          The new support was meant to be a plugin, either simply bringing back the old backend in plugin-form, potentially labelling it as just existing for compat reasons, or by writing plugins using platform-native APIs (WinINet, etc.)

          I suggest making a feature request about bringing FTP support back if you need it, as I cannot get something like this prioritized without showing there is demand :)

          J 1 Reply Last reply 12 May 2022, 12:31
          0
          • M manordheim
            12 May 2022, 12:01

            Hello!

            Sorry! This is partially my fault :)
            The original plan for Qt 6 was to remove FTP from the default distribution given low usage and relevance in today's tech stacks. I, of course, knew that some people would still be interested in FTP, so the plan was to 'check the pulse' in 6.0/6.1 to see if anyone was actually missing the support. In the end there has been little-to-no demand to bring it back so it was never prioritized work internally.

            The reason for why the old support was removed that it was a somewhat brittle backend which was just based on the old QFtp code. It had limited support for normal FTP functionality today, and limited error handling. It was thus a cause for multiple bug-reports for 'simple' things with only complex/risky solutions.

            The new support was meant to be a plugin, either simply bringing back the old backend in plugin-form, potentially labelling it as just existing for compat reasons, or by writing plugins using platform-native APIs (WinINet, etc.)

            I suggest making a feature request about bringing FTP support back if you need it, as I cannot get something like this prioritized without showing there is demand :)

            J Offline
            J Offline
            JonB
            wrote on 12 May 2022, 12:31 last edited by
            #5

            @manordheim said in QT6 QNetworkRequest and FTP:

            remove FTP from the default distribution given low usage and relevance in today's tech stacks

            I do not doubt that you know/have your finger on the IT pulse more than I, but I'm pretty surprised by this. Since when has FTP become irrelevant?

            SGaistS M 2 Replies Last reply 12 May 2022, 19:40
            0
            • J JonB
              12 May 2022, 12:31

              @manordheim said in QT6 QNetworkRequest and FTP:

              remove FTP from the default distribution given low usage and relevance in today's tech stacks

              I do not doubt that you know/have your finger on the IT pulse more than I, but I'm pretty surprised by this. Since when has FTP become irrelevant?

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on 12 May 2022, 19:40 last edited by
              #6

              Hi,

              @JonB said in QT6 QNetworkRequest and FTP:

              @manordheim said in QT6 QNetworkRequest and FTP:

              remove FTP from the default distribution given low usage and relevance in today's tech stacks

              I do not doubt that you know/have your finger on the IT pulse more than I, but I'm pretty surprised by this. Since when has FTP become irrelevant?

              I would say since S3, DropBox and the likes have become widely adopted as a mean to store and share files.

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

              1 Reply Last reply
              0
              • J JonB
                12 May 2022, 12:31

                @manordheim said in QT6 QNetworkRequest and FTP:

                remove FTP from the default distribution given low usage and relevance in today's tech stacks

                I do not doubt that you know/have your finger on the IT pulse more than I, but I'm pretty surprised by this. Since when has FTP become irrelevant?

                M Offline
                M Offline
                manordheim
                wrote on 13 May 2022, 11:32 last edited by
                #7

                @JonB
                As Samuel said, for file sharing in an organization there are more mainstream ways of doing it now. And it doesn't include windows network shares :)
                For simple upload/download it's quite simple to set up a http server end-point (think transmitting logs/artifacts). Which will likely also have better performance compared to FTP.
                When exactly it happened is hard to tell, though I wouldn't say it's fully irrelevant yet. But it seems closer than ever :).

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  JonB
                  wrote on 13 May 2022, 11:50 last edited by JonB
                  #8

                  @manordheim , @SGaist
                  Thank you for your comments. My commercial usage is obviously very different from yours, or maybe you are more talking about social/personal users.

                  When we "share" files --- in either direction --- with customers etc. (external), we certainly do not use e.g. DropBox. They expect FTP access, with suitable username & password. When they download from our website (or if required upload to a secure area) they expect FTP to be available; or they may have their own FTP server for exchanging files with us. When I manage our website I use FTP to upload (large) files there. And so on.

                  So for my own part I would like to see Qt continue to support FTP. (Though I do not use Qt in my commercial life, only in my personal "hobby" life.) And over the years of answering questions here I have seen many requests/questions for FTP functionality, where we referred users to the old QFtp support. But maybe it's less now.

                  But I bow to your superior experience.

                  M 1 Reply Last reply 23 May 2022, 13:33
                  1
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 13 May 2022, 19:12 last edited by
                    #9

                    Nothing wrong with using FTP (unless it's not sftp ;-)).

                    As for the support, if memory serves QFtp was already turned into a module. So if you should be able to use it. You can also help with its maintenance to keep it alive :-)

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

                    1 Reply Last reply
                    1
                    • J JonB
                      13 May 2022, 11:50

                      @manordheim , @SGaist
                      Thank you for your comments. My commercial usage is obviously very different from yours, or maybe you are more talking about social/personal users.

                      When we "share" files --- in either direction --- with customers etc. (external), we certainly do not use e.g. DropBox. They expect FTP access, with suitable username & password. When they download from our website (or if required upload to a secure area) they expect FTP to be available; or they may have their own FTP server for exchanging files with us. When I manage our website I use FTP to upload (large) files there. And so on.

                      So for my own part I would like to see Qt continue to support FTP. (Though I do not use Qt in my commercial life, only in my personal "hobby" life.) And over the years of answering questions here I have seen many requests/questions for FTP functionality, where we referred users to the old QFtp support. But maybe it's less now.

                      But I bow to your superior experience.

                      M Offline
                      M Offline
                      manordheim
                      wrote on 23 May 2022, 13:33 last edited by
                      #10

                      @JonB I'd prefer no bowing. :) As I said, FTP is certainly still in use. And what you describe of passing files across companies with FTP is something I'm familiar with. But that's usually been a process outside the application. The workflow I've heard of in those cases is usually:

                      1. generate reports/results with the relevant application
                      2. upload to customer's ftp/make available on our ftp using a cmdline tool or some gui application

                      Though your experience could differ. :)

                      1 Reply Last reply
                      1
                      • kkoehneK Offline
                        kkoehneK Offline
                        kkoehne
                        Moderators
                        wrote on 23 May 2022, 15:05 last edited by
                        #11

                        @SGaist said in QT6 QNetworkRequest and FTP:

                        Nothing wrong with using FTP

                        Well, there's lots of things wrong with FTP :) Can't remember who brought this link up, maybe it as even in some discussions about this very feature of Qt Network: https://mywiki.wooledge.org/FtpMustDie

                        The security issue is probably fixed by SFTP, and 'don't break my workflow' is a valid requirement for a framework ... but I found the page entertaining.

                        Director R&D, The Qt Company

                        SGaistS 1 Reply Last reply 23 May 2022, 15:26
                        0
                        • kkoehneK kkoehne
                          23 May 2022, 15:05

                          @SGaist said in QT6 QNetworkRequest and FTP:

                          Nothing wrong with using FTP

                          Well, there's lots of things wrong with FTP :) Can't remember who brought this link up, maybe it as even in some discussions about this very feature of Qt Network: https://mywiki.wooledge.org/FtpMustDie

                          The security issue is probably fixed by SFTP, and 'don't break my workflow' is a valid requirement for a framework ... but I found the page entertaining.

                          SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 23 May 2022, 15:26 last edited by
                          #12

                          @kkoehne Heeeey you cut the line short ! The content of the parenthesis was the most important !

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

                          1 Reply Last reply
                          0
                          • C Offline
                            C Offline
                            Charlie8741
                            wrote on 27 Aug 2022, 12:16 last edited by Charlie8741
                            #13

                            Hi,
                            Sorry to reply to this old thread, but do we have any news regarding FTP support ? I use it in my personal project and that missing support hold me from moving to Qt6...

                            Thank you for your time !

                            1 Reply Last reply
                            1
                            • Mike Trahearn 0M Offline
                              Mike Trahearn 0M Offline
                              Mike Trahearn 0
                              wrote on 27 Aug 2022, 21:23 last edited by
                              #14

                              As a major worldwide company whose customers are also major and worldwide, we and our customers expect to be able to use FTP as a means of communication between our devices. Yes we have and use other modern and appropriate mechanisms available for primary communication protocols but we still have current use cases which will outlast the Qt6 lifetime. Please give bringing FTP back to Qt6 some serious consideration otherwise large companies with heavy investments in Qt are going to have to consider what would be a costly course of direction change with significant D&D and no ROI. Thank you.

                              J 1 Reply Last reply 28 Aug 2022, 06:34
                              0
                              • Mike Trahearn 0M Mike Trahearn 0
                                27 Aug 2022, 21:23

                                As a major worldwide company whose customers are also major and worldwide, we and our customers expect to be able to use FTP as a means of communication between our devices. Yes we have and use other modern and appropriate mechanisms available for primary communication protocols but we still have current use cases which will outlast the Qt6 lifetime. Please give bringing FTP back to Qt6 some serious consideration otherwise large companies with heavy investments in Qt are going to have to consider what would be a costly course of direction change with significant D&D and no ROI. Thank you.

                                J Offline
                                J Offline
                                JonB
                                wrote on 28 Aug 2022, 06:34 last edited by
                                #15

                                @Mike-Trahearn-0
                                I do not disagree with you, but be aware this is a user forum. We have no influence over what The Qt Company does. Your comments would be best addressed to them.

                                Mike Trahearn 0M 1 Reply Last reply 29 Aug 2022, 00:20
                                0
                                • J JonB
                                  28 Aug 2022, 06:34

                                  @Mike-Trahearn-0
                                  I do not disagree with you, but be aware this is a user forum. We have no influence over what The Qt Company does. Your comments would be best addressed to them.

                                  Mike Trahearn 0M Offline
                                  Mike Trahearn 0M Offline
                                  Mike Trahearn 0
                                  wrote on 29 Aug 2022, 00:20 last edited by
                                  #16

                                  @JonB Thank you - they are very much aware I can assure you.

                                  1 Reply Last reply
                                  0
                                  • JKSHJ Offline
                                    JKSHJ Offline
                                    JKSH
                                    Moderators
                                    wrote on 1 Sept 2022, 02:04 last edited by
                                    #17

                                    Is there a strong reason why it must be done via a Qt-ish FTP API? How about using QProcess to run cURL?

                                    • https://en.wikipedia.org/wiki/CURL
                                    • https://everything.curl.dev/ftp/upload

                                    ...or perhaps WinSCP if you're supporting Windows only?

                                    • https://winscp.net/eng/docs/executables
                                    • https://winscp.net/eng/docs/scripting

                                    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                                    1 Reply Last reply
                                    1
                                    • L Offline
                                      L Offline
                                      legerborea
                                      wrote on 6 Sept 2022, 09:20 last edited by
                                      #18

                                      @JKSH
                                      Because using external binaries is not practical to implement. You have to manage binaries for all supported platforms (windows, macOS, linux) but the hard part is parsing output data, if you need to get status of download/upload, you have to parse output of curl.
                                      Yes, that can be done ! But this is not very practical...

                                      JKSHJ 1 Reply Last reply 6 Sept 2022, 12:58
                                      1
                                      • L legerborea
                                        6 Sept 2022, 09:20

                                        @JKSH
                                        Because using external binaries is not practical to implement. You have to manage binaries for all supported platforms (windows, macOS, linux) but the hard part is parsing output data, if you need to get status of download/upload, you have to parse output of curl.
                                        Yes, that can be done ! But this is not very practical...

                                        JKSHJ Offline
                                        JKSHJ Offline
                                        JKSH
                                        Moderators
                                        wrote on 6 Sept 2022, 12:58 last edited by
                                        #19

                                        @legerborea said in QT6 QNetworkRequest and FTP:

                                        Because using external binaries is not practical to implement. You have to manage binaries for all supported platforms (windows, macOS, linux) but the hard part is parsing output data, if you need to get status of download/upload, you have to parse output of curl.

                                        OK, how about using the libcurl library instead? That's very cross-platform.

                                        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                                        J 1 Reply Last reply 6 Sept 2022, 16:41
                                        3
                                        • JKSHJ JKSH
                                          6 Sept 2022, 12:58

                                          @legerborea said in QT6 QNetworkRequest and FTP:

                                          Because using external binaries is not practical to implement. You have to manage binaries for all supported platforms (windows, macOS, linux) but the hard part is parsing output data, if you need to get status of download/upload, you have to parse output of curl.

                                          OK, how about using the libcurl library instead? That's very cross-platform.

                                          J Offline
                                          J Offline
                                          JonB
                                          wrote on 6 Sept 2022, 16:41 last edited by
                                          #20

                                          @JKSH That is a more viable answer! :)

                                          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