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. Upload file with QAccessManager - problem with url

Upload file with QAccessManager - problem with url

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 512 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.
  • D Offline
    D Offline
    dabla24
    wrote on 2 Sept 2014, 09:06 last edited by
    #1

    Hi, I got problem with typing good url address to upload file to my server. This is my whole code:

    @void FttpClient::ConnectWithServer()
    {
    // create file
    QString filename="/home/vla/Documents/Data.txt";
    QFile file( filename );
    if ( file.open(QIODevice::ReadWrite) )
    {
    QTextStream stream( &file );
    stream << "I write somethign hjeer e" << endl;
    }

    // handle connection
    manager = new QNetworkAccessManager(this&#41;;
    connect(manager, SIGNAL(finished(QNetworkReply*&#41;&#41;,this, SLOT(replyFinished(QNetworkReply*)));
    
    url.setUrl("ftp://blalala.bugs3.com/");
    qDebug("set url ");
    url.setUserName("userName");
    qDebug("set user name ");
    url.setPassword("pw");
    qDebug("set pw ");
    url.setPort(21);
    qDebug("set port");
    
    manager->put(QNetworkRequest(url),&file);
    qDebug("put method from manager");
    file.close();
     qDebug("file closed");
    

    }

    // and the last method when I get reply for posting
    // action
    void FttpClient::replyFinished (QNetworkReply *reply)
    {
    qDebug("reply getted");
    if(reply->error())
    {
    qDebug() << "ERROR!";
    qDebug() << reply->errorString();
    qDebug() << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
    qDebug() << reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString();
    }
    else
    {
    qDebug() << reply->header(QNetworkRequest::ContentTypeHeader).toString();
    qDebug() << reply->header(QNetworkRequest::LastModifiedHeader).toDateTime().toString();;
    qDebug() << reply->header(QNetworkRequest::ContentLengthHeader).toULongLong();
    qDebug() << reply->header(QNetworkRequest::CookieHeader).toString();
    qDebug() << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
    qDebug() << reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString();

    }
    reply->deleteLater();
    

    }@

    when address look like in the code above, output which I got says me :

    " Cannot open ftp://userName:pw@blalala.bugs3.com:21/: is a directory"

    and the userName is the values set here:
    @ url.setUserName("userName");@
    the same with pw.

    When I try to add in url some directory like this
    @url.setUrl("ftp://blalala.bugs3.com/mydire")@

    bq. the output looks like this
    set url
    set user name
    set pw
    set port
    put method from manager
    file closed
    The program has unexpectedly finished.

    so I don't get any info, even response isn't invoked. I tried to set some file in url which should be created, but the result is the same as with adding directory to url so the app finishing unexpected...

    What is the problem here ?

    I would be grateful for any advices. If u need more details just give me a word.

    EDIT the url(ftp://blalala.bugs3.com/), user name and pw which I', using inside the code was tested with filezilla, so it's impossible that I putting wrong credential.

    1 Reply Last reply
    0

    1/1

    2 Sept 2014, 09:06

    • Login

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