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. uploadProgress signal emitted 0/0 with long delay
QtWS25 Last Chance

uploadProgress signal emitted 0/0 with long delay

Scheduled Pinned Locked Moved Solved General and Desktop
qnetworkreplyqnetworkrequestuploadqnetworkaccessm
7 Posts 2 Posters 1.6k 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.
  • Y Offline
    Y Offline
    yasen
    wrote on 1 Apr 2019, 15:01 last edited by
    #1

    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
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 1 Apr 2019, 20:32 last edited by
      #2

      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 2 Apr 2019, 06:12
      0
      • S SGaist
        1 Apr 2019, 20:32

        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
        Y Offline
        Y Offline
        yasen
        wrote on 2 Apr 2019, 06:12 last edited by
        #3

        @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
        0
        • Y Offline
          Y Offline
          yasen
          wrote on 3 Apr 2019, 16:39 last edited by
          #4

          no thoughts?

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 3 Apr 2019, 20:23 last edited by
            #5

            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
            0
            • Y Offline
              Y Offline
              yasen
              wrote on 4 Apr 2019, 10:07 last edited by
              #6

              Qt 5.12.2 same problem

              1 Reply Last reply
              0
              • Y Offline
                Y Offline
                yasen
                wrote on 4 Apr 2019, 18:32 last edited by
                #7

                Tested on another server, everything works fine

                1 Reply Last reply
                0

                1/7

                1 Apr 2019, 15:01

                • Login

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