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. upload bitrate
Forum Updated to NodeBB v4.3 + New Features

upload bitrate

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 313 Views 1 Watching
  • 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.
  • S Offline
    S Offline
    satyanarayana143
    wrote on last edited by
    #1

    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)));
    
    JonBJ 1 Reply Last reply
    0
    • S satyanarayana143

      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)));
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @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?

      1 Reply Last reply
      0
      • S Offline
        S Offline
        satyanarayana143
        wrote on last edited by
        #3

        my bandwidth is less i want send onlinestream and file at a time i want to limit upload bandwith for file

        JonBJ 1 Reply Last reply
        0
        • S satyanarayana143

          my bandwidth is less i want send onlinestream and file at a time i want to limit upload bandwith for file

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @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 via QNetworkRequest. 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.

          1 Reply Last reply
          1

          • Login

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