Important: Please read the Qt Code of Conduct -

uploadProgress signal emitted 0/0 with long delay

  • 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\""));
    QHttpPart fileTypePart;
    fileTypePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"file_type\""));
    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);
    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);
    connect(manager, SIGNAL(finished(QNetworkReply*)),
            this, SLOT   (uploadDone(QNetworkReply*)));
    connect(reply, SIGNAL(uploadProgress(qint64, qint64)),
            this, SLOT  (uploadProgress(qint64, qint64)));

  • Lifetime Qt Champion

    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

  • @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)

  • no thoughts?

  • Lifetime Qt Champion

    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.

  • Qt 5.12.2 same problem

  • Tested on another server, everything works fine