Results 1 to 3 of 3

Thread: List files on ftp server using QNetworkAccessManager

  1. #1
    Join Date
    Jan 2012
    Posts
    6
    Thanks
    2

    Default List files on ftp server using QNetworkAccessManager

    Hi,

    I need to get a list of files from a ftp server and as Qt-Doc recommended wanted to use the QNetworkAccessManager for that. But I have no clue where to start. With QFtp everything is so easy .

    My code to connect isbasically this:

    Qt Code:
    1. QNetworkAccessManager* qnam = new QNetworkAccessManager(this);
    2. QUrl url = QUrl();
    3. url.setHost(QString("host"));
    4. url.setUserName(QString("user"));
    5. url.setPassword(QString("pswd"));
    6. url.setPort(21);
    7. QNetworkRequest nRequest(url);
    8. this->qnam->get(nRequest);
    To copy to clipboard, switch view to plain text mode 

    But the ftp server log doesn't show any response to this. Which it did, when I tried QFtp.

    Is there somewhere a nice tutorial for QNam or even good sample code for this?

    Thanks for your help,
    bbg

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: List files on ftp server using QNetworkAccessManager

    Your code is going to fail because you haven't provided a URL to access, e.g.:
    Qt Code:
    1. QUrl url("ftp://my.server.com/somefile.txt");
    To copy to clipboard, switch view to plain text mode 

    The QNetworkAccessManager support for FTP extends to get and put requests only, so you should use QFtp if you are doing more with your FTP server.

  3. #3
    Join Date
    Jan 2012
    Posts
    6
    Thanks
    2

    Default Re: List files on ftp server using QNetworkAccessManager

    That answers my questions. Thanks .

Similar Threads

  1. QNetworkAccessManager timeout when server is down?
    By martinn in forum Qt Programming
    Replies: 8
    Last Post: 9th January 2014, 16:32
  2. QNetworkAccessmanager and ICY-Server
    By jörg in forum Qt Programming
    Replies: 2
    Last Post: 12th August 2011, 12:36
  3. QNetworkAccessManager and get FTP content list
    By dickymoe in forum Qt Programming
    Replies: 1
    Last Post: 4th May 2011, 19:37
  4. Downloading multiple files using QNetworkAccessManager
    By aurorius in forum Qt Programming
    Replies: 3
    Last Post: 7th August 2009, 10:51
  5. upload files using QNetworkAccessManager
    By Raajesh in forum Qt Programming
    Replies: 1
    Last Post: 30th June 2008, 19:43

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.