Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Showcase
  4. [Library] QFtpCompat – async FTP client for Qt6
Qt 6.11 is out! See what's new in the release blog

[Library] QFtpCompat – async FTP client for Qt6

Scheduled Pinned Locked Moved Showcase
3 Posts 2 Posters 1.2k Views 1 Watching
  • 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.
  • J.HilkJ Offline
    J.HilkJ Offline
    J.Hilk
    Moderators
    wrote on last edited by J.Hilk
    #1

    Hi all,

    while migrating a Qt5 project to Qt6 I ran into the problem – QFtp is gone and QNetworkAccessManager apparently doesn't do FTP anymore. I needed to talk to an embedded PLC over FTP and couldn't find anything that was CMake-ready and covered the commands I needed, so I ended up writing my own.

    The API is queue-based and signal-driven like the old QFtp, but it's not a drop-in replacement – URLs are used instead of separate host/port parameters, and credentials are passed via QUrl rather than a dedicated login call.

    auto *ftp = new QFtpCompat(this);
    
    connect(ftp, &QFtpCompat::commandFinished, this, [ftp](int, bool error) {
        if (error) qWarning() << ftp->errorString();
    });
    connect(ftp, &QFtpCompat::listInfo, this, [](const QFtpCompatDirEntry &e) {
        qDebug() << e.name() << e.size();
    });
    
    ftp->open(QUrl("ftp://user:pass@192.168.1.1/"));
    ftp->list(QUrl("ftp://192.168.1.1/data/"));
    
    QByteArray buf;
    ftp->get(QUrl("ftp://192.168.1.1/data/config.cfg"), &buf);
    ftp->put(QUrl("ftp://192.168.1.1/data/config.cfg"), buf);
    

    Explicit FTPS (AUTH TLS) and Implicit FTPS are supported as well:

    ftp->open(QUrl("ftps://192.168.1.1/"), QFtpCompat::EncryptionMode::Explicit);
    connect(ftp, &QFtpCompat::sslErrors, ftp, &QFtpCompat::ignoreSslErrors);
    

    Posting this as-is – it works for my use case and has a small integration test suite, but hasn't seen much use beyond that. Feedback and PRs welcome.

    https://github.com/DeiVadder/QFtpCompat


    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


    Q: What's that?
    A: It's blue light.
    Q: What does it do?
    A: It turns blue.

    JonBJ 1 Reply Last reply
    4
    • J.HilkJ J.Hilk marked this topic as a regular topic on
    • J.HilkJ J.Hilk

      Hi all,

      while migrating a Qt5 project to Qt6 I ran into the problem – QFtp is gone and QNetworkAccessManager apparently doesn't do FTP anymore. I needed to talk to an embedded PLC over FTP and couldn't find anything that was CMake-ready and covered the commands I needed, so I ended up writing my own.

      The API is queue-based and signal-driven like the old QFtp, but it's not a drop-in replacement – URLs are used instead of separate host/port parameters, and credentials are passed via QUrl rather than a dedicated login call.

      auto *ftp = new QFtpCompat(this);
      
      connect(ftp, &QFtpCompat::commandFinished, this, [ftp](int, bool error) {
          if (error) qWarning() << ftp->errorString();
      });
      connect(ftp, &QFtpCompat::listInfo, this, [](const QFtpCompatDirEntry &e) {
          qDebug() << e.name() << e.size();
      });
      
      ftp->open(QUrl("ftp://user:pass@192.168.1.1/"));
      ftp->list(QUrl("ftp://192.168.1.1/data/"));
      
      QByteArray buf;
      ftp->get(QUrl("ftp://192.168.1.1/data/config.cfg"), &buf);
      ftp->put(QUrl("ftp://192.168.1.1/data/config.cfg"), buf);
      

      Explicit FTPS (AUTH TLS) and Implicit FTPS are supported as well:

      ftp->open(QUrl("ftps://192.168.1.1/"), QFtpCompat::EncryptionMode::Explicit);
      connect(ftp, &QFtpCompat::sslErrors, ftp, &QFtpCompat::ignoreSslErrors);
      

      Posting this as-is – it works for my use case and has a small integration test suite, but hasn't seen much use beyond that. Feedback and PRs welcome.

      https://github.com/DeiVadder/QFtpCompat

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @J.Hilk
      Hi there. Excellent stuff for the community, thank you.

      I had a brief look through https://github.com/DeiVadder/QFtpCompat text, and some of the code.

      If I were to use FTP again --- as I did years ago --- I would "miss" these features:

      • NLST command. Clients may map this to a DIR command rather than LIST, IIRC.
      • ASCII mode states "Command sent; CRLF normalisation not yet applied". If that means it does not do LF<->CR-LF translation.
      • Active rather than just Passive mode.

      Just noting these. Quite understand if you want to stop at what you have now. :)

      J.HilkJ 1 Reply Last reply
      1
      • JonBJ JonB

        @J.Hilk
        Hi there. Excellent stuff for the community, thank you.

        I had a brief look through https://github.com/DeiVadder/QFtpCompat text, and some of the code.

        If I were to use FTP again --- as I did years ago --- I would "miss" these features:

        • NLST command. Clients may map this to a DIR command rather than LIST, IIRC.
        • ASCII mode states "Command sent; CRLF normalisation not yet applied". If that means it does not do LF<->CR-LF translation.
        • Active rather than just Passive mode.

        Just noting these. Quite understand if you want to stop at what you have now. :)

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        @JonB

        Like I said, this is currently just the bare minimum viable project for my port 😄

        Feel free to contribute if you'd like ^^
        Otherwise, development will probably continue once I have a bit more free time again.

        Any help, feedback, or pull requests are always appreciated!


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        1 Reply Last reply
        1

        • Login

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