Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Downloading file from FTP server

    General and Desktop
    windows 10 ftp ftp repository download file
    5
    13
    10026
    Loading More Posts
    • 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.
    • mrdebug
      mrdebug last edited by

      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

      Qjay 1 Reply Last reply Reply Quote 2
      • mrjj
        mrjj Lifetime Qt Champion @Qjay last edited by mrjj

        @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 Reply Quote 4
        • Qjay
          Qjay @mrdebug last edited by

          @mrdebug thanks i will try it out :D

          1 Reply Last reply Reply Quote 0
          • VRonin
            VRonin last edited by

            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 Reply Quote 4
            • mrjj
              mrjj Lifetime Qt Champion last edited by

              @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 :)

              VRonin 1 Reply Last reply Reply Quote 0
              • J
                James Haitching last edited by

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

                1 Reply Last reply Reply Quote 0
                • VRonin
                  VRonin @mrjj last edited by VRonin

                  @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

                  Qjay 1 Reply Last reply Reply Quote 5
                  • Qjay
                    Qjay last edited by

                    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 Reply Quote 0
                    • Qjay
                      Qjay @VRonin last edited by

                      @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 Reply Quote 0
                      • VRonin
                        VRonin last edited by VRonin

                        #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 Reply Quote 5
                        • First post
                          Last post