Post upload file send only 16kb
-
@JonB When i should close file? After post statement?
QTWindow is simple QMainWindow class.
Updated
m_requestReply = { m_netManager->post( request, m_requestFile ) }; m_requestFile->close(); Upload... Upload success. QIODevice::read (QFile, "/home/vsw/test2.jpg"): device not open Upload error code: 99 0 0 Upload finished. Upload error: Unknown error@vicsoftware said in Post upload file send only 16kb:
@JonB When i should close file? After post statement?
data must be open for reading and must remain valid until the finished() signal is emitted for this reply.
So in
onRequestFinishedyou need to close it, and (presumably)delete m_requestFile. You also need that done in the error case (assuming that does not generate aQNetworkReply::finished).In that light, your placement of
m_requestFile->close();above is wrong now and will cause thedevice not open, get that fixed and try again. -
@vicsoftware said in Post upload file send only 16kb:
@JonB When i should close file? After post statement?
data must be open for reading and must remain valid until the finished() signal is emitted for this reply.
So in
onRequestFinishedyou need to close it, and (presumably)delete m_requestFile. You also need that done in the error case (assuming that does not generate aQNetworkReply::finished).In that light, your placement of
m_requestFile->close();above is wrong now and will cause thedevice not open, get that fixed and try again.@JonB Tried close file and close reply:
void QTWindow::onRequestFinished( QNetworkReply * reply ) { reply->close(); reply->deleteLater(); // m_requestFile->close(); // delete m_requestFile; log( "Upload finished." ); }Same issue.
As i see finished does not fired. It waits some responce or somthing else.
Upload...
Upload success.
16384 27025
16384 27025 -
@JonB Tried close file and close reply:
void QTWindow::onRequestFinished( QNetworkReply * reply ) { reply->close(); reply->deleteLater(); // m_requestFile->close(); // delete m_requestFile; log( "Upload finished." ); }Same issue.
As i see finished does not fired. It waits some responce or somthing else.
Upload...
Upload success.
16384 27025
16384 27025@vicsoftware
To be clear: I only put those remarks in for your good coding behaviour (hence the "And just BTW:"). They were not expected to have any effect on whatever your upload problem is. -
@vicsoftware
To be clear: I only put those remarks in for your good coding behaviour (hence the "And just BTW:"). They were not expected to have any effect on whatever your upload problem is.@JonB Yes, i simply try all advises, cause i fight with this second day. Read all forums and decided to write here.
I can take any other c++ library, but should understand it.First i tried Multipart https://doc.qt.io/qt-5/qhttpmultipart.html
Issue exactly the same.
But python and curl works on my pc and other person. -
@JonB Yes, i simply try all advises, cause i fight with this second day. Read all forums and decided to write here.
I can take any other c++ library, but should understand it.First i tried Multipart https://doc.qt.io/qt-5/qhttpmultipart.html
Issue exactly the same.
But python and curl works on my pc and other person.@vicsoftware
I haven't Googled, but if I were in your position I would go find the simplest example of a file upload example out there for Qt. There must be many, maybe even on the docs page, there are also probably answers with it on this forum. Try the standard code others use and see if that works on bigger file. -
Hi,
Did you also check that your headers are all correct ?
-
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.