Post upload file send only 16kb
-
Check for limits on the server you are posting to. Does other software allow you to post bigger files? We have a server we wrote in python that had a limit of 40MB. It was a self imposed limit.
@fcarney Any files with any libraries. But not Qt. May be it is bug?
-
Looks like some sort of config limit:
https://doc.qt.io/qt-5/qnetworkrequest.html#http2Configuration -
@SGaist I think yes. I tried many combinations. I compare headers from curl and python requests and they works. May be Qt network engine needs additional headers, but it is abnormal.
Now it works with curl cpp wrapper in same class in same function without any problems.
-
Did you try following the example of QHttpMultiPart ? Adding only the minimal set of headers like the authentication and nothing else ?
-
Looks like some sort of config limit:
https://doc.qt.io/qt-5/qnetworkrequest.html#http2Configuration@fcarney Tried:
QHttp2Configuration conf = request.http2Configuration(); conf.setMaxFrameSize( 100 * 1024 * 1024 ); request.setHttp2Configuration( conf );And got this:
Upload... qt.network.http2: Maximum frame size to advertise is invalid Upload success. 16384 27025 16384 27025 27025 27025 0 0 Upload finished. 10 Mb file Upload... qt.network.http2: Maximum frame size to advertise is invalid Upload success. 16384 10669810 16384 10669810 16384 10669810 16384 10669810 Upload error code: 2 0 0 Upload finished. Upload error: Connection closedIt is something new.
And it is also very slow.
-
Did you try following the example of QHttpMultiPart ? Adding only the minimal set of headers like the authentication and nothing else ?
@SGaist Yes, i did all Googled combinations to upload file via QT nm.post, including qtmultipart examples from stackoverflow. Always failed.
-
Also, for size we use QVariant(device->size()) in the content header content length. Not sure if that would make a difference. I believe size is an integer of some type.
@fcarney Tried that:
request.setHeader( QNetworkRequest::ContentLengthHeader, QVariant{ m_requestFile->size() } ); request.setHeader( QNetworkRequest::ContentTypeHeader, QVariant{ "image/jpeg" } );Same bug.
May be QT developers can help?
-
I just looked at some code we use. It uses multipart and we can send files larger than 16KB. I cannot share it though.
@fcarney I tried multipart. But we need several headers and file contents only. Without parsing parts and boundaries on server side cause server save all data to file.
-
@fcarney Tried that:
request.setHeader( QNetworkRequest::ContentLengthHeader, QVariant{ m_requestFile->size() } ); request.setHeader( QNetworkRequest::ContentTypeHeader, QVariant{ "image/jpeg" } );Same bug.
May be QT developers can help?
@vicsoftware said in Post upload file send only 16kb:
request.setHeader( QNetworkRequest::ContentTypeHeader, QVariant{ m_requestFile->size() } );
request.setHeader( QNetworkRequest::ContentLengthHeader, QVariant{ "image/jpeg" } );Are you really setting length to "image/jpeg"? And type to size?
-
@vicsoftware said in Post upload file send only 16kb:
request.setHeader( QNetworkRequest::ContentTypeHeader, QVariant{ m_requestFile->size() } );
request.setHeader( QNetworkRequest::ContentLengthHeader, QVariant{ "image/jpeg" } );Are you really setting length to "image/jpeg"? And type to size?
@fcarney Sorry, I'm tired. Fixed. Tried both ). Same result.