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. Downloading file from FTP server
QtWS25 Last Chance

Downloading file from FTP server

Scheduled Pinned Locked Moved Unsolved General and Desktop
windows 10ftpftp repositorydownloadfile
13 Posts 5 Posters 11.6k 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
    mrdebug
    wrote on 25 Feb 2018, 09:57 last edited by
    #4

    In order to have an http server service based on Qt I'm using Poco
    https://pocoproject.org/ It is very great!
    It has got an ftp component too.

    Need programmers to hire?
    www.labcsp.com
    www.denisgottardello.it
    GMT+1
    Skype: mrdebug

    Q 1 Reply Last reply 25 Feb 2018, 18:10
    2
    • Q Qjay
      25 Feb 2018, 09:40

      i am not sure if curl or wget will work on windows . Moreover i want to distribute this utility program so i cannot be sure that others might also have same environment as mine

      M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 25 Feb 2018, 17:57 last edited by mrjj
      #5

      @Qjay
      Hi
      Both wget and CURL runs on windows and linux.
      CURL also run macOS. (CURL even runs in DOS ;)
      https://curl.haxx.se/download.html
      https://eternallybored.org/misc/wget/

      You can just include the tools (.exe) in apps folder.
      They are standalone cmd line, requiring no install and will
      only add 10 MB to the installer size.

      Anyway, not knowing what you really need, maybe sing POCO or QFTP/ something else integrated is better.
      Running a cmdline tool with QProcess is just very easy if all you need is to download a predefined file.

      1 Reply Last reply
      4
      • M mrdebug
        25 Feb 2018, 09:57

        In order to have an http server service based on Qt I'm using Poco
        https://pocoproject.org/ It is very great!
        It has got an ftp component too.

        Q Offline
        Q Offline
        Qjay
        wrote on 25 Feb 2018, 18:10 last edited by
        #6

        @mrdebug thanks i will try it out :D

        1 Reply Last reply
        0
        • V Offline
          V Offline
          VRonin
          wrote on 26 Feb 2018, 08:52 last edited by
          #7

          Curl has a C API https://curl.haxx.se/libcurl/ with bindings in other languages like C++ (http://www.curlpp.org/) so you can build it and link to it on basically all platforms Qt supports.

          Having said that, if you have an ftp url and just want to download it, QNetworkAccessManager is more than enough to achieve your target

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          4
          • M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 26 Feb 2018, 08:59 last edited by
            #8

            @VRonin said in Downloading file from FTP server:

            QNetworkAccessManager

            Hi
            I could not find a sample for download but this uploads to ftp
            https://evileg.com/en/post/255/

            Please update if you find downloading from ftp sample :)

            V 1 Reply Last reply 26 Feb 2018, 09:12
            0
            • J Offline
              J Offline
              James Haitching
              wrote on 26 Feb 2018, 09:03 last edited by
              #9

              you can use qftp class derectly in qt4
              if you are using qt5 ,you can get this class from github

              1 Reply Last reply
              0
              • M mrjj
                26 Feb 2018, 08:59

                @VRonin said in Downloading file from FTP server:

                QNetworkAccessManager

                Hi
                I could not find a sample for download but this uploads to ftp
                https://evileg.com/en/post/255/

                Please update if you find downloading from ftp sample :)

                V Offline
                V Offline
                VRonin
                wrote on 26 Feb 2018, 09:12 last edited by VRonin
                #10

                @mrjj said in Downloading file from FTP server:

                Please update if you find downloading from ftp sample

                It's just a normal get request, as it was http:

                #include <QCoreApplication>
                #include <QNetworkAccessManager>
                #include <QNetworkReply>
                #include <QNetworkRequest>
                int main(int argc, char *argv[])
                {
                    QCoreApplication a(argc,argv);
                    QNetworkAccessManager netMan;
                    QNetworkReply* const repl = netMan.get(QNetworkRequest(QUrl::fromUserInput(R"**(ftp://131.225.104.13/linux/.snapshot/NDMP_AUTO_SNAPSHOT3210/fermi/contrib/obsolete/video/nvidia/5328/NVIDIA.5328.README.txt)**")));
                    QObject::connect(repl,&QNetworkReply::readyRead,[repl]()->void{
                         qDebug().noquote() << repl->readAll();
                     });
                    QObject::connect(repl,QOverload<QNetworkReply::NetworkError>::of(&QNetworkReply::error),[repl]()->void{
                         qDebug() << "Error: " + repl->errorString();
                     });
                    return a.exec();
                }
                

                @James-Haitching said in Downloading file from FTP server:

                you can get [QFtp] from github

                No, that module is outdated and not maintained. Never use old code when you have a chance of using cryptography. If you want to do more advanced stuff (like getting directory listing) then use libcurl/curlpp

                "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                ~Napoleon Bonaparte

                On a crusade to banish setIndexWidget() from the holy land of Qt

                Q 1 Reply Last reply 1 Mar 2018, 18:32
                5
                • Q Offline
                  Q Offline
                  Qjay
                  wrote on 1 Mar 2018, 15:36 last edited by
                  #11

                  thanks for so many solutions . I will try all of that but for the time being ( as it was urgent) i used python ( ftp module) and tkinter for a very quick gui .

                  1 Reply Last reply
                  0
                  • V VRonin
                    26 Feb 2018, 09:12

                    @mrjj said in Downloading file from FTP server:

                    Please update if you find downloading from ftp sample

                    It's just a normal get request, as it was http:

                    #include <QCoreApplication>
                    #include <QNetworkAccessManager>
                    #include <QNetworkReply>
                    #include <QNetworkRequest>
                    int main(int argc, char *argv[])
                    {
                        QCoreApplication a(argc,argv);
                        QNetworkAccessManager netMan;
                        QNetworkReply* const repl = netMan.get(QNetworkRequest(QUrl::fromUserInput(R"**(ftp://131.225.104.13/linux/.snapshot/NDMP_AUTO_SNAPSHOT3210/fermi/contrib/obsolete/video/nvidia/5328/NVIDIA.5328.README.txt)**")));
                        QObject::connect(repl,&QNetworkReply::readyRead,[repl]()->void{
                             qDebug().noquote() << repl->readAll();
                         });
                        QObject::connect(repl,QOverload<QNetworkReply::NetworkError>::of(&QNetworkReply::error),[repl]()->void{
                             qDebug() << "Error: " + repl->errorString();
                         });
                        return a.exec();
                    }
                    

                    @James-Haitching said in Downloading file from FTP server:

                    you can get [QFtp] from github

                    No, that module is outdated and not maintained. Never use old code when you have a chance of using cryptography. If you want to do more advanced stuff (like getting directory listing) then use libcurl/curlpp

                    Q Offline
                    Q Offline
                    Qjay
                    wrote on 1 Mar 2018, 18:32 last edited by
                    #12

                    @VRonin said in Downloading file from FTP server:

                    QNetworkAccessManager netMan;
                    QNetworkReply* const repl = netMan.get(QNetworkRequest(QUrl::fromUserInput(R"(ftp://131.225.104.13/linux/.snapshot/NDMP_AUTO_SNAPSHOT3210/fermi/contrib/obsolete/video/nvidia/5328/NVIDIA.5328.README.txt)")));
                    QObject::connect(repl,&QNetworkReply::readyRead,repl->void{
                    qDebug().noquote() << repl->readAll();
                    });
                    QObject::connect(repl,QOverloadQNetworkReply::NetworkError::of(&QNetworkReply::error),repl->void{
                    qDebug() << "Error: " + repl->errorString();
                    });

                    suppose i have to pass login details too , how can i do it ? FTP server is password protected

                    1 Reply Last reply
                    0
                    • V Offline
                      V Offline
                      VRonin
                      wrote on 1 Mar 2018, 18:37 last edited by VRonin 3 Jan 2018, 18:44
                      #13
                      #include <QCoreApplication>
                      #include <QNetworkAccessManager>
                      #include <QNetworkReply>
                      #include <QNetworkRequest>
                      int main(int argc, char *argv[])
                      {
                          QCoreApplication a(argc,argv);
                          QNetworkAccessManager netMan;
                          QNetworkReply* const repl = netMan.get(QNetworkRequest(QUrl::fromUserInput(R"**(ftp://131.225.104.13/linux/.snapshot/NDMP_AUTO_SNAPSHOT3210/fermi/contrib/obsolete/video/nvidia/5328/NVIDIA.5328.README.txt)**")));
                          QObject::connect(repl,&QNetworkReply::readyRead,[repl]()->void{
                               qDebug().noquote() << repl->readAll();
                           });
                          QObject::connect(repl,QOverload<QNetworkReply::NetworkError>::of(&QNetworkReply::error),[repl]()->void{
                               qDebug() << "Error: " + repl->errorString();
                           });
                          QObject::connect(repl,&QNetworkReply::finished,repl,&QNetworkReply::deleteLater);
                          QObject::connect(&netMan,&QNetworkAccessManager::authenticationRequired,repl,[repl](QNetworkReply *reply, QAuthenticator *authenticator)->void{
                              if(reply!=repl) 
                                  return;
                              aAuthenticator->setUser("MyUserName");
                              aAuthenticator->setPassword("MyPassword");
                          });
                          return a.exec();
                      }
                      

                      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                      ~Napoleon Bonaparte

                      On a crusade to banish setIndexWidget() from the holy land of Qt

                      1 Reply Last reply
                      5

                      13/13

                      1 Mar 2018, 18:37

                      • Login

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