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

22nd July 2018, 09:54
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?

23rd July 2018, 20:51
QNetworkAccessManager::put() can also take a QByteArray - no need to create a file and open it with QFile... http://doc.qt.io/qt-5/qnetworkaccessmanager.html#put-1