Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    General and Desktop
    https post upload
    4
    5
    818
    Loading More Posts
    • 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
      Rami Rosenbaum last edited by

      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 Reply Quote 0
      • K
        koahnig @Rami Rosenbaum last edited by

        @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 Reply Quote 0
        • SGaist
          SGaist Lifetime Qt Champion last edited by

          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 Reply Quote 1
          • R
            Rami Rosenbaum @koahnig last edited by

            @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 Reply Quote 0
            • Christian Ehrlicher
              Christian Ehrlicher Lifetime Qt Champion last edited by

              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 Reply Quote 3
              • First post
                Last post