Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved uploadProgress signal emitted 0/0 with long delay

    General and Desktop
    qnetworkreply qnetworkrequest upload qnetworkaccessm
    2
    7
    776
    Loading More Posts
    • 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.
    • Y
      yasen last edited by

      uploadProgress signal not emitted real upload progress. When i upload large file, progress emited 3 times, example:
      16384 / 10175221
      6766592 / 10175221
      10175221 / 10175221
      but signal 0 / 0 emited with long delay. I think that the signal is emitted when the file is uploaded to some intermediate buffer, and not to the remote server. How to get real upload progress?
      Code example:

      QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
      
      QHttpPart profileIdPart;
      profileIdPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"profile_id\""));
      profileIdPart.setBody(GlobalsArgs::profileID.toUtf8());
      multiPart->append(profileIdPart);
      
      QHttpPart fileTypePart;
      fileTypePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"file_type\""));
      fileTypePart.setBody(fileT.toUtf8());
      multiPart->append(fileTypePart);
      
      fileObj = new QFile(file);
      QHttpPart imagePart;
      imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"file\"; filename=\"" + fileObj->fileName() +"\""));
      imagePart.setHeader(QNetworkRequest::ContentLengthHeader, fileInfo.size());
      imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/octet-stream"));
      fileObj->open(QIODevice::ReadOnly | QIODevice::Unbuffered);
      imagePart.setBodyDevice(fileObj);
      fileObj->setParent(multiPart);
      multiPart->append(imagePart);
      
      QUrl url(GlobalsArgs::uploadURL + "/files/");
      QByteArray headerRowName;
      headerRowName.append(" Bearer " + GlobalsArgs::uploadToken);
      
      QNetworkRequest request(url);
      request.setRawHeader("Authorization", headerRowName);
      request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
      request.setAttribute(QNetworkRequest::DoNotBufferUploadDataAttribute, true);
      
      manager = new QNetworkAccessManager(this);
      reply = manager->post(request, multiPart);
      multiPart->setParent(reply);
      
      connect(manager, SIGNAL(finished(QNetworkReply*)),
              this, SLOT   (uploadDone(QNetworkReply*)));
      
      connect(reply, SIGNAL(uploadProgress(qint64, qint64)),
              this, SLOT  (uploadProgress(qint64, qint64)));
      
      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi and welcome to devnet,

        You should add:

        • Which version of Qt
        • Which OS you are running your application
        • Whether it happens with all the files, if not, what is the size trigger
        • What kind of server do you have on the other side

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        Y 1 Reply Last reply Reply Quote 0
        • Y
          yasen @SGaist last edited by

          @SGaist ty for reply,

          Version Qt: 5.11.2
          OS version: Windows 7 (64bit)
          Happens with all files types and size
          server side: node.js (express.js)

          1 Reply Last reply Reply Quote 0
          • Y
            yasen last edited by

            no thoughts?

            1 Reply Last reply Reply Quote 0
            • SGaist
              SGaist Lifetime Qt Champion last edited by

              Well, I would test against another server, I haven't had that problem yet.

              You might also want to update to Qt 5.12.2.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply Reply Quote 0
              • Y
                yasen last edited by

                Qt 5.12.2 same problem

                1 Reply Last reply Reply Quote 0
                • Y
                  yasen last edited by

                  Tested on another server, everything works fine

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post