<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Post upload file send  only 16kb]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">QTWindow constructor:</p>
<pre><code>
m_netManager = new QNetworkAccessManager{ this };
connect( m_netManager, &amp; QNetworkAccessManager::finished, this, &amp; QTWindow::onRequestFinished );
</code></pre>
<p dir="auto">void QTWindow::sendImageHttp( const QString &amp; jpgPath )<br />
{<br />
log( "Upload..." );</p>
<pre><code>QUrl url{ "https://xxxxxxxxxxxx/photo" };

QNetworkRequest request{ url };

m_requestFile = { new QFile{ jpgPath } };
if( not m_requestFile-&gt;open( QIODevice::ReadOnly ) )
{
    log( "Failed to load file: " + jpgPath );
    return;
}
const auto fileSize{ m_requestFile-&gt;size() };
QByteArray fileLength;
fileLength.setNum( fileSize );
QFileInfo fi{ jpgPath };

request.setRawHeader( "User-Agent", "SlabTools/1.0" );
request.setRawHeader( "Accept-Encoding", "gzip, deflate" );
request.setRawHeader( "Accept", "*/*" );
request.setRawHeader( "Connection", "keep-alive" );
request.setRawHeader( "authorization", "Basic xxxxxxxxxxxxxx" );
request.setRawHeader( "cache-control", "no-cache" );
request.setRawHeader( "slb", "00199975" );
request.setRawHeader( "spytnik", "0" );
request.setRawHeader( "Content-Type", "image/jpeg" );
request.setRawHeader( "Content-Length", fileLength );

m_requestReply = { m_netManager-&gt;post( request, m_requestFile ) };
connect( m_requestReply, &amp; QNetworkReply::uploadProgress, this, &amp; QTWindow::onReplyUploadProgress );
connect( m_requestReply, &amp; QNetworkReply::finished, this, &amp; QTWindow::onRequestFinished );
connect( m_requestReply, QOverload&lt; QNetworkReply::NetworkError &gt;::of( &amp; QNetworkReply::error ),
         [ = ]( QNetworkReply::NetworkError code )
{
    log( "Upload error code: " + QString::number( code ) );
    log( "Upload error: " + m_requestReply-&gt;errorString() );
});
</code></pre>
<p dir="auto">);<br />
log( "Upload success." );<br />
}</p>
<pre><code>
Upload &lt; 16kb file - success.

If file &gt; 16kb then after several attempts ( wait about 1 minute for every attempt ) and server close connection with error 2.

</code></pre>
<p dir="auto">Upload...<br />
Upload success.<br />
16384 27025<br />
16384 27025<br />
16384 27025<br />
16384 27025<br />
Upload error code: 2<br />
0 0<br />
Upload finished.<br />
Upload error: Connection closed</p>
<pre><code>

Here is python code and it works with any file:

</code></pre>
<p dir="auto">try:<br />
headers = {<br />
'authorization': "Basic xxxxxxxxxxxxxxxx",<br />
'cache-control': "no-cache",<br />
"slb": "00199975",<br />
"spytnik": "0"<br />
}<br />
file = open("test2.jpg", "rb")</p>
<pre><code>response = requests.request("POST", verify=True, url="https://xxxxxxxxxxxxxx/photo", data=file, headers=head&gt;

print( "Response:", response.json() )
</code></pre>
<p dir="auto">except Exception as e:<br />
print( "Exception:", e )</p>
<pre><code>

QHttpMultipart same issue.

It is Ubuntu 20, QT5.15.2. Also i tried on Windows QT 5.15 same issue.

Please help.

Best regards, Viktor.</code></pre>
]]></description><link>https://forum.qt.io/topic/127006/post-upload-file-send-only-16kb</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Apr 2026 15:24:24 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/127006.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 26 May 2021 11:29:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Post upload file send  only 16kb on Wed, 26 May 2021 21:30:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/fcarney">@<bdi>fcarney</bdi></a> Sorry, I'm tired. Fixed. Tried both ). Same result.</p>
]]></description><link>https://forum.qt.io/post/661799</link><guid isPermaLink="true">https://forum.qt.io/post/661799</guid><dc:creator><![CDATA[vicsoftware]]></dc:creator><pubDate>Wed, 26 May 2021 21:30:22 GMT</pubDate></item><item><title><![CDATA[Reply to Post upload file send  only 16kb on Wed, 26 May 2021 21:21:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vicsoftware">@<bdi>vicsoftware</bdi></a> said in <a href="/post/661796">Post upload file send only 16kb</a>:</p>
<blockquote>
<p dir="auto">request.setHeader( QNetworkRequest::ContentTypeHeader, QVariant{ m_requestFile-&gt;size() } );<br />
request.setHeader( QNetworkRequest::ContentLengthHeader, QVariant{ "image/jpeg" } );</p>
</blockquote>
<p dir="auto">Are you really setting length to "image/jpeg"?  And type to size?</p>
]]></description><link>https://forum.qt.io/post/661798</link><guid isPermaLink="true">https://forum.qt.io/post/661798</guid><dc:creator><![CDATA[fcarney]]></dc:creator><pubDate>Wed, 26 May 2021 21:21:28 GMT</pubDate></item><item><title><![CDATA[Reply to Post upload file send  only 16kb on Wed, 26 May 2021 21:20:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/fcarney">@<bdi>fcarney</bdi></a> 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.</p>
]]></description><link>https://forum.qt.io/post/661797</link><guid isPermaLink="true">https://forum.qt.io/post/661797</guid><dc:creator><![CDATA[vicsoftware]]></dc:creator><pubDate>Wed, 26 May 2021 21:20:05 GMT</pubDate></item><item><title><![CDATA[Reply to Post upload file send  only 16kb on Wed, 26 May 2021 21:24:07 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/fcarney">@<bdi>fcarney</bdi></a> Tried that:</p>
<pre><code>request.setHeader( QNetworkRequest::ContentLengthHeader, QVariant{ m_requestFile-&gt;size() } );
request.setHeader( QNetworkRequest::ContentTypeHeader, QVariant{ "image/jpeg" } );
</code></pre>
<p dir="auto">Same bug.</p>
<p dir="auto">May be QT developers can help?</p>
]]></description><link>https://forum.qt.io/post/661796</link><guid isPermaLink="true">https://forum.qt.io/post/661796</guid><dc:creator><![CDATA[vicsoftware]]></dc:creator><pubDate>Wed, 26 May 2021 21:24:07 GMT</pubDate></item><item><title><![CDATA[Reply to Post upload file send  only 16kb on Wed, 26 May 2021 20:46:08 GMT]]></title><description><![CDATA[<p dir="auto">Also, for size we use QVariant(device-&gt;size()) in the content header content length.  Not sure if that would make a difference.  I believe size is an integer of some type.</p>
]]></description><link>https://forum.qt.io/post/661794</link><guid isPermaLink="true">https://forum.qt.io/post/661794</guid><dc:creator><![CDATA[fcarney]]></dc:creator><pubDate>Wed, 26 May 2021 20:46:08 GMT</pubDate></item><item><title><![CDATA[Reply to Post upload file send  only 16kb on Wed, 26 May 2021 20:35:05 GMT]]></title><description><![CDATA[<p dir="auto">I just looked at some code we use.  It uses multipart and we can send files larger than 16KB.  I cannot share it though.</p>
]]></description><link>https://forum.qt.io/post/661792</link><guid isPermaLink="true">https://forum.qt.io/post/661792</guid><dc:creator><![CDATA[fcarney]]></dc:creator><pubDate>Wed, 26 May 2021 20:35:05 GMT</pubDate></item><item><title><![CDATA[Reply to Post upload file send  only 16kb on Wed, 26 May 2021 19:51:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> Yes, i did all Googled combinations to upload file via QT nm.post, including qtmultipart examples from stackoverflow. Always failed.</p>
]]></description><link>https://forum.qt.io/post/661788</link><guid isPermaLink="true">https://forum.qt.io/post/661788</guid><dc:creator><![CDATA[vicsoftware]]></dc:creator><pubDate>Wed, 26 May 2021 19:51:09 GMT</pubDate></item><item><title><![CDATA[Reply to Post upload file send  only 16kb on Wed, 26 May 2021 19:52:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/fcarney">@<bdi>fcarney</bdi></a> Tried:</p>
<pre><code>QHttp2Configuration conf = request.http2Configuration();
conf.setMaxFrameSize( 100 * 1024 * 1024 );
request.setHttp2Configuration( conf );
</code></pre>
<p dir="auto">And got this:</p>
<pre><code>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 closed

</code></pre>
<p dir="auto">It is something new.</p>
<p dir="auto">And it is also very slow.</p>
]]></description><link>https://forum.qt.io/post/661786</link><guid isPermaLink="true">https://forum.qt.io/post/661786</guid><dc:creator><![CDATA[vicsoftware]]></dc:creator><pubDate>Wed, 26 May 2021 19:52:32 GMT</pubDate></item><item><title><![CDATA[Reply to Post upload file send  only 16kb on Wed, 26 May 2021 19:36:36 GMT]]></title><description><![CDATA[<p dir="auto">Did you try following the example of QHttpMultiPart ? Adding only the minimal set of headers like the authentication and nothing else ?</p>
]]></description><link>https://forum.qt.io/post/661785</link><guid isPermaLink="true">https://forum.qt.io/post/661785</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Wed, 26 May 2021 19:36:36 GMT</pubDate></item><item><title><![CDATA[Reply to Post upload file send  only 16kb on Wed, 26 May 2021 19:42:01 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> 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.</p>
<p dir="auto">Now it works with curl cpp wrapper in same class in same function without any problems.</p>
]]></description><link>https://forum.qt.io/post/661781</link><guid isPermaLink="true">https://forum.qt.io/post/661781</guid><dc:creator><![CDATA[vicsoftware]]></dc:creator><pubDate>Wed, 26 May 2021 19:42:01 GMT</pubDate></item><item><title><![CDATA[Reply to Post upload file send  only 16kb on Wed, 26 May 2021 19:12:38 GMT]]></title><description><![CDATA[<p dir="auto">Looks like some sort of config limit:<br />
<a href="https://doc.qt.io/qt-5/qnetworkrequest.html#http2Configuration" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-5/qnetworkrequest.html#http2Configuration</a></p>
]]></description><link>https://forum.qt.io/post/661780</link><guid isPermaLink="true">https://forum.qt.io/post/661780</guid><dc:creator><![CDATA[fcarney]]></dc:creator><pubDate>Wed, 26 May 2021 19:12:38 GMT</pubDate></item><item><title><![CDATA[Reply to Post upload file send  only 16kb on Wed, 26 May 2021 19:08:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/fcarney">@<bdi>fcarney</bdi></a> Any files with any libraries. But not Qt. May be it is bug?</p>
]]></description><link>https://forum.qt.io/post/661779</link><guid isPermaLink="true">https://forum.qt.io/post/661779</guid><dc:creator><![CDATA[vicsoftware]]></dc:creator><pubDate>Wed, 26 May 2021 19:08:38 GMT</pubDate></item><item><title><![CDATA[Reply to Post upload file send  only 16kb on Wed, 26 May 2021 19:01:51 GMT]]></title><description><![CDATA[<p dir="auto">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.</p>
]]></description><link>https://forum.qt.io/post/661777</link><guid isPermaLink="true">https://forum.qt.io/post/661777</guid><dc:creator><![CDATA[fcarney]]></dc:creator><pubDate>Wed, 26 May 2021 19:01:51 GMT</pubDate></item><item><title><![CDATA[Reply to Post upload file send  only 16kb on Wed, 26 May 2021 18:50:19 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Did you also check that your headers are all correct ?</p>
]]></description><link>https://forum.qt.io/post/661772</link><guid isPermaLink="true">https://forum.qt.io/post/661772</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Wed, 26 May 2021 18:50:19 GMT</pubDate></item><item><title><![CDATA[Reply to Post upload file send  only 16kb on Wed, 26 May 2021 12:25:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vicsoftware">@<bdi>vicsoftware</bdi></a><br />
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.</p>
]]></description><link>https://forum.qt.io/post/661684</link><guid isPermaLink="true">https://forum.qt.io/post/661684</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Wed, 26 May 2021 12:25:05 GMT</pubDate></item><item><title><![CDATA[Reply to Post upload file send  only 16kb on Wed, 26 May 2021 12:28:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> Yes, i simply try all advises, cause i fight with this second day. Read all forums and decided to write here.<br />
I can take any other c++ library, but should understand it.</p>
<p dir="auto">First i tried Multipart <a href="https://doc.qt.io/qt-5/qhttpmultipart.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-5/qhttpmultipart.html</a><br />
Issue exactly the same.<br />
But python and curl works on my pc and other person.</p>
]]></description><link>https://forum.qt.io/post/661681</link><guid isPermaLink="true">https://forum.qt.io/post/661681</guid><dc:creator><![CDATA[vicsoftware]]></dc:creator><pubDate>Wed, 26 May 2021 12:28:59 GMT</pubDate></item><item><title><![CDATA[Reply to Post upload file send  only 16kb on Wed, 26 May 2021 12:12:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vicsoftware">@<bdi>vicsoftware</bdi></a><br />
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.</p>
]]></description><link>https://forum.qt.io/post/661678</link><guid isPermaLink="true">https://forum.qt.io/post/661678</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Wed, 26 May 2021 12:12:39 GMT</pubDate></item><item><title><![CDATA[Reply to Post upload file send  only 16kb on Wed, 26 May 2021 12:13:18 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> Tried close file and close reply:</p>
<pre><code>void QTWindow::onRequestFinished( QNetworkReply * reply )
{
    reply-&gt;close();
    reply-&gt;deleteLater();
//    m_requestFile-&gt;close();
//    delete m_requestFile;
    log( "Upload finished." );
}
</code></pre>
<p dir="auto">Same issue.</p>
<p dir="auto">As i see finished does not fired. It waits some responce or somthing else.</p>
<p dir="auto">Upload...<br />
Upload success.<br />
16384 27025<br />
16384 27025</p>
]]></description><link>https://forum.qt.io/post/661677</link><guid isPermaLink="true">https://forum.qt.io/post/661677</guid><dc:creator><![CDATA[vicsoftware]]></dc:creator><pubDate>Wed, 26 May 2021 12:13:18 GMT</pubDate></item><item><title><![CDATA[Reply to Post upload file send  only 16kb on Wed, 26 May 2021 12:10:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vicsoftware">@<bdi>vicsoftware</bdi></a> said in <a href="/post/661671">Post upload file send only 16kb</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> When i should close file? After post statement?</p>
</blockquote>
<blockquote>
<p dir="auto">data must be open for reading and must remain valid until the finished() signal is emitted for this reply.</p>
</blockquote>
<p dir="auto">So in <code>onRequestFinished</code> you need to close it, and (presumably) <code>delete m_requestFile</code>.  You also need that done in the error case (assuming that does not generate a <code>QNetworkReply::finished</code>).</p>
<p dir="auto">In that light, your placement of <code>m_requestFile-&gt;close();</code> above is wrong now and will cause the <code>device not open</code>, get that fixed and try again.</p>
]]></description><link>https://forum.qt.io/post/661673</link><guid isPermaLink="true">https://forum.qt.io/post/661673</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Wed, 26 May 2021 12:10:26 GMT</pubDate></item><item><title><![CDATA[Reply to Post upload file send  only 16kb on Wed, 26 May 2021 11:55:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> When i should close file? After post statement?</p>
<p dir="auto">QTWindow is simple QMainWindow class.</p>
<p dir="auto"><strong>Updated</strong></p>
<pre><code>m_requestReply = { m_netManager-&gt;post( request, m_requestFile ) };
m_requestFile-&gt;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
</code></pre>
]]></description><link>https://forum.qt.io/post/661671</link><guid isPermaLink="true">https://forum.qt.io/post/661671</guid><dc:creator><![CDATA[vicsoftware]]></dc:creator><pubDate>Wed, 26 May 2021 11:55:58 GMT</pubDate></item><item><title><![CDATA[Reply to Post upload file send  only 16kb on Wed, 26 May 2021 11:50:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vicsoftware">@<bdi>vicsoftware</bdi></a><br />
I am unsure whether a <code>QNetworkRequest</code>  instance still needs to live after you have done <code>m_requestReply = { m_netManager-&gt;post( request, m_requestFile ) };</code>, or at that point only the reply object is needed.</p>
<p dir="auto">Why don't you shove in a <code>static</code> or a <code>new</code> temporarily and see if that makes any difference?  [<strong>EDIT</strong> <a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a> has seemed to say you do need this to persist, so as he says it will want to be a member variable.]</p>
<p dir="auto">I <em>assume</em> your <code>QTWindow</code> persists?  And you do not dispose <code>m_requestFile = { new QFile{ jpgPath } };</code>?</p>
<p dir="auto">And just BTW: do you eventually dispose <code>m_requestFile</code> and close it first?</p>
]]></description><link>https://forum.qt.io/post/661668</link><guid isPermaLink="true">https://forum.qt.io/post/661668</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Wed, 26 May 2021 11:50:42 GMT</pubDate></item><item><title><![CDATA[Reply to Post upload file send  only 16kb on Wed, 26 May 2021 11:46:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vicsoftware">@<bdi>vicsoftware</bdi></a> said in <a href="/post/661665">Post upload file send only 16kb</a>:</p>
<blockquote>
<p dir="auto">Should i QNetworkRequest make global too?</p>
</blockquote>
<p dir="auto">Not global but member variable.</p>
]]></description><link>https://forum.qt.io/post/661666</link><guid isPermaLink="true">https://forum.qt.io/post/661666</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Wed, 26 May 2021 11:46:20 GMT</pubDate></item><item><title><![CDATA[Reply to Post upload file send  only 16kb on Wed, 26 May 2021 11:44:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> Really file is class member variable ( fixed ), m_netManager, m_replyRequest too.<br />
Should i QNetworkRequest make global too?</p>
]]></description><link>https://forum.qt.io/post/661665</link><guid isPermaLink="true">https://forum.qt.io/post/661665</guid><dc:creator><![CDATA[vicsoftware]]></dc:creator><pubDate>Wed, 26 May 2021 11:44:29 GMT</pubDate></item><item><title><![CDATA[Reply to Post upload file send  only 16kb on Wed, 26 May 2021 11:40:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vicsoftware">@<bdi>vicsoftware</bdi></a><br />
If I'm not mistaken: all/most of you variables are local to your method, they will go out of scope when then exits, which is more or less as soon as you as your do the <code>post()</code>.  You need to keep necessaries in existence till the request has finished.</p>
<p dir="auto">Python code is more likely to keep objects around than C++ code, where you have to be explicit.</p>
<p dir="auto">Let us know if that is indeed the reason here?</p>
<p dir="auto"><strong>EDIT</strong> Upon reflection, I'm not so sure.  I now see you are using <code>m_...</code> variables.</p>
]]></description><link>https://forum.qt.io/post/661664</link><guid isPermaLink="true">https://forum.qt.io/post/661664</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Wed, 26 May 2021 11:40:47 GMT</pubDate></item></channel></rss>