upload bitrate
-
I am using Qhttp multipart to upload file in qt i want control upload speed in Qmultipart method how can i do.
Below is my code
QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
QHttpPart imagePart;m_nFileName = "Test.pdf"; imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"file\"; filename=\""+ m_nFileName + "\"")); QHttpPart textPart; textPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"name\"")); textPart.setBody("test");/* test is the name I give to my file in the server */ QString m_nFilePath = "/home/yazmi/Downloads/"+m_nFileName; QFile *file = new QFile(m_nFilePath); file->open(QIODevice::ReadOnly); imagePart.setBodyDevice(file); file->setParent(multiPart); // we cannot delete the file now, so delete it with the multiPart multiPart->append(textPart); multiPart->append(imagePart); QUrl url("http://127.0.0.1:3001/upload"); QNetworkRequest request(url); QNetworkAccessManager *networkManager= new QNetworkAccessManager; reply = networkManager->post(request, multiPart); multiPart->setParent(reply); // delete the multiPart with the reply qDebug() << "Start Time:" << QDateTime::currentDateTime(); connect(reply, SIGNAL(finished()),this, SLOT (uploadDone())); connect(reply, SIGNAL(uploadProgress(qint64, qint64)),this, SLOT (uploadProgress(qint64, qint64)));
-
@satyanarayana143
QHttpMultiPart
"resembles a MIME multipart message to be sent over HTTP". It's just a format for an HTTP payload. There is no "speed" associated with it. The speed is determined by the HTTP connection. You cannot affect that, and why would you want to anyway? -
my bandwidth is less i want send onlinestream and file at a time i want to limit upload bandwith for file
-
@satyanarayana143
That does not alter the fact that it has nothing to do with multipart. If you could influence the speed at all it would be viaQNetworkRequest
. And as I said I do not believe that is possible. See this forum's post https://forum.qt.io/topic/80799/how-to-limit-upload-speed or https://stackoverflow.com/questions/44906835/how-to-limit-the-upload-speed-of-an-application for similar conclusion.