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 file via HTTP - callback/signal for feeding data from buffer (not via QFile)
QtWS25 Last Chance

Upload file via HTTP - callback/signal for feeding data from buffer (not via QFile)

Scheduled Pinned Locked Moved Unsolved General and Desktop
https postupload
5 Posts 4 Posters 1.3k 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.
  • R Offline
    R Offline
    Rami Rosenbaum
    wrote on last edited by
    #1

    Hi,
    I'm porting a GUI Windows application to Linux, and am using Qt, mainly for it's GUI framework, but also for all the good Qt has to offer.

    The original code uses libcurl for HTP communication, uploading files. The curl_multi_ asynchronous API is used, for non-blocking behavior.
    Files, which are dynamically created, are being uploaded. a WRITE callback is being set to cURL, and is called so the user will 'feed' cURL with more data to upload.

    What I know and have seen in Qt, is that a QFile is being passes, and everything is being done 'behind the scene'. signals of progress and finish are emitted, as apposed to a GET request, where readyRead() signal is emitted.

    I thought of creating a temporary file, just before using the standard Qt method, and passing this file to the NAM, but am hoping for a more elegant solution.
    Is there a way to use Qt the way cURL works?
    Thanks

    K 1 Reply Last reply
    0
    • R Rami Rosenbaum

      Hi,
      I'm porting a GUI Windows application to Linux, and am using Qt, mainly for it's GUI framework, but also for all the good Qt has to offer.

      The original code uses libcurl for HTP communication, uploading files. The curl_multi_ asynchronous API is used, for non-blocking behavior.
      Files, which are dynamically created, are being uploaded. a WRITE callback is being set to cURL, and is called so the user will 'feed' cURL with more data to upload.

      What I know and have seen in Qt, is that a QFile is being passes, and everything is being done 'behind the scene'. signals of progress and finish are emitted, as apposed to a GET request, where readyRead() signal is emitted.

      I thought of creating a temporary file, just before using the standard Qt method, and passing this file to the NAM, but am hoping for a more elegant solution.
      Is there a way to use Qt the way cURL works?
      Thanks

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @Rami-Rosenbaum

      Hi and welcome to devnet forum

      Why do you intend to create a temporary file before uploading with Qt?

      Vote the answer(s) that helped you to solve your issue(s)

      R 1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi and welcome to devnet,

        IIRC, you can use either a QIODevice, a QByteArray or QHttpMultiPart. This should allow you to build your buffer and send the data the way you want.

        Hope it helps

        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
        1
        • K koahnig

          @Rami-Rosenbaum

          Hi and welcome to devnet forum

          Why do you intend to create a temporary file before uploading with Qt?

          R Offline
          R Offline
          Rami Rosenbaum
          wrote on last edited by
          #4

          @koahnig The current code is built for the cURL API, which sends (or buffers internally) the data in chunks, calling the WRITE callback for the user to give it another chunk of data to send.
          I need somewhere to change the behavior, so better not change the 'heart' of the code, but the edge, so I thought of using the same WRITE callback to read all the data into a file, and then pass that file to the QNetworkAccessManager.

          1 Reply Last reply
          0
          • Christian EhrlicherC Online
            Christian EhrlicherC Online
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            http://www.qtcentre.org/threads/69650-Upload-file-via-HTTP-callback-signal-for-feeding-data-from-buffer-(not-via-QFile)

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            3

            • Login

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