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.
  • mrdebugM Offline
    mrdebugM Offline
    mrdebug
    wrote on 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

    QjayQ 1 Reply Last reply
    2
    • QjayQ Qjay

      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

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on 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
      • mrdebugM mrdebug

        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.

        QjayQ Offline
        QjayQ Offline
        Qjay
        wrote on last edited by
        #6

        @mrdebug thanks i will try it out :D

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on 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
          • mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on 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 :)

            VRoninV 1 Reply Last reply
            0
            • J Offline
              J Offline
              James Haitching
              wrote on 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
              • mrjjM mrjj

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

                VRoninV Offline
                VRoninV Offline
                VRonin
                wrote on 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

                QjayQ 1 Reply Last reply
                5
                • QjayQ Offline
                  QjayQ Offline
                  Qjay
                  wrote on 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
                  • VRoninV 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

                    QjayQ Offline
                    QjayQ Offline
                    Qjay
                    wrote on 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
                    • VRoninV Offline
                      VRoninV Offline
                      VRonin
                      wrote on last edited by VRonin
                      #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

                      • Login

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