uploadProgress signal emitted 0/0 with long delay
Solved
General and Desktop
-
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)));
-
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
-
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.