[Qt-interest] QNetworkAccessManager::post() with a single streaming form data element

Ben Martin monkeyiq at users.sourceforge.net
Sun Aug 9 03:23:11 CEST 2009


Hi,
  I'm looking at using QtNetwork to post data to various web services.
It appears somewhat common for services to use HTTP post and accept
large content as a single form element, eg flickr [2] using photo, and
vimeo [1] using "video".

  Looking at the Qt API, it appears if you want to supply a streaming
parameter for HTTP post [3], you have to form the entire request
yourself. 

Basically what I'm after is to be able to set the api_key, signature,
method name and other REST API fluff with QUrl.addQueryItem() but set
the large data element photo/video using a QIODevice as a data buffer.
This way I can set the QUrl for the QNetworkRequest and then
QNetworkAccessManager::post() it to the server and start writing to the
photo/video QIODevice and stream the large content over the post, having
the QIODevice act as a queue between the desktop client (which can write
as fast as it likes) and the Internet connection which might only stream
at 20kb/sec. The client should also be able to use the QIODevice as a
crude "upload progress" by watching the data flow.

Most of the code I've dug up so far creates the HTTP post by hand,
writing each form element as "Content-Disposition: form-data; " etc.
Is there a way to use the QUrl/NetReq/NetAM triple but get a QIODevice
which can be used for writing the "larger content" which might be a
100mb video file? 

Using post() [3] with a QIODev would appear to do it, but then you seem
to be busted back to writing the whole post yourself too. 

[1] http://www.vimeo.com/api/docs/upload
[2] http://www.flickr.com/services/api/upload.api.html
[3] http://doc.qtsoftware.com/4.5/qnetworkaccessmanager.html#post
[4] http://doc.qtsoftware.com/4.5/qurl.html#addEncodedQueryItem

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090809/b2a4cdbc/attachment.bin 


More information about the Qt-interest-old mailing list