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. FTP transfer error AuthenticationRequiredError although user and password are set
Forum Updated to NodeBB v4.3 + New Features

FTP transfer error AuthenticationRequiredError although user and password are set

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 197 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.
  • T Offline
    T Offline
    Thomas 63
    wrote on 11 May 2024, 07:32 last edited by
    #1

    Hello all

    I try to upload a file to a directory via ftp, which has worked some time ago.
    I dont know what has changed, but I have the strange error Message "QNetworkReply::AuthenticationRequiredError" although I have set user and password.

    void MainWindow::on_btn_upload_file_clicked(){
        QNetworkAccessManager *NetworkAccessManager = new QNetworkAccessManager();
        QString zielname = "C:/Users/tomax/Desktop/test.pdf";
        QString filepath = "ftp://server.de:21/homepath/public_html/docs/test.pdf";
        QFile *QuellFile = new QFile(C:/Users/tomax/Desktop/test.pdf);
    
        QUrl url;
        url.setScheme("ftp");
        url.setHost("server.de"); //FTP server oder domain
        url.setPath("zielserver.de/public_html/docs/test.pdf"); // hier Zielname einfügen
        url.setUserName("username");
        url.setPassword("passwort");
        url.setPort(21);
    
        qDebug() << url.userName();
        qDebug() << url.password();
        QNetworkRequest request(url);
    
        if(QuellFile->open(QIODevice::ReadWrite)){
            QNetworkReply *reply = NetworkAccessManager->put(request, QuellFile);
            connect(reply, &QNetworkReply::uploadProgress, this, &MainWindow::uploadProgress);
            connect(reply, SIGNAL(uploadProgress(qint64, qint64)), this, SLOT(uploadProgress(qint64,qint64)));
            connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(loadError(QNetworkReply::NetworkError)));
        }
    }
    
    qDebug() << url.userName(); and
    qDebug() << url.password();
    

    give the correct username and password.

    Any idea?

    C 1 Reply Last reply 11 May 2024, 08:00
    0
    • T Thomas 63
      11 May 2024, 07:32

      Hello all

      I try to upload a file to a directory via ftp, which has worked some time ago.
      I dont know what has changed, but I have the strange error Message "QNetworkReply::AuthenticationRequiredError" although I have set user and password.

      void MainWindow::on_btn_upload_file_clicked(){
          QNetworkAccessManager *NetworkAccessManager = new QNetworkAccessManager();
          QString zielname = "C:/Users/tomax/Desktop/test.pdf";
          QString filepath = "ftp://server.de:21/homepath/public_html/docs/test.pdf";
          QFile *QuellFile = new QFile(C:/Users/tomax/Desktop/test.pdf);
      
          QUrl url;
          url.setScheme("ftp");
          url.setHost("server.de"); //FTP server oder domain
          url.setPath("zielserver.de/public_html/docs/test.pdf"); // hier Zielname einfügen
          url.setUserName("username");
          url.setPassword("passwort");
          url.setPort(21);
      
          qDebug() << url.userName();
          qDebug() << url.password();
          QNetworkRequest request(url);
      
          if(QuellFile->open(QIODevice::ReadWrite)){
              QNetworkReply *reply = NetworkAccessManager->put(request, QuellFile);
              connect(reply, &QNetworkReply::uploadProgress, this, &MainWindow::uploadProgress);
              connect(reply, SIGNAL(uploadProgress(qint64, qint64)), this, SLOT(uploadProgress(qint64,qint64)));
              connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(loadError(QNetworkReply::NetworkError)));
          }
      }
      
      qDebug() << url.userName(); and
      qDebug() << url.password();
      

      give the correct username and password.

      Any idea?

      C Offline
      C Offline
      ChrisW67
      wrote on 11 May 2024, 08:00 last edited by
      #2

      @Thomas-63 Please copy and paste from your actual, compiling code. The fifth line of your snippet will not compile.

      When you say that the debug output, "give the correct username and password," I assume you mean the value you expected to see. QNetworkReply::AuthenticationRequiredError means, "the remote server requires authentication to serve the content but the credentials provided were not accepted (if any)." So, either the credentials are not being received at the other end or they are incorrect.

      The credentials in your code snippet are clearly not the real ones, so it's not possible for us to independently check.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Thomas 63
        wrote on 11 May 2024, 11:46 last edited by
        #3

        Hey, I found it!

        I used the long version of the upload path instead of the path from the FTP-User's access point

        1 Reply Last reply
        0
        • T Thomas 63 has marked this topic as solved on 11 May 2024, 11:47

        1/3

        11 May 2024, 07:32

        • Login

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