PDA

View Full Version : Downloading file problem



Kaluss
6th August 2014, 20:07
Hello,
im trying to develop download app, but I stuck on following problem:

1)I sen a download request by QNetworkAccessManager
2)On finished event I got QNetwork *reply which size is correct
3)but the size of: reply->readAll().length() is incorrect and when I save the file is too small.

Does anywone know where is the problem or what Im doing wrong?

BR
Tomek

ChrisW67
6th August 2014, 23:24
Hard to say without seeing your code. However, if you do this,


qDebug() << reply->readAll().length();
// then open file and
file.write(reply->readAll());

You get an empty file because there is no more data to read after the first call to readAll().

Kaluss
7th August 2014, 09:50
Generally situation looks like this:
void UpdateMgr::onDownloadingFinished( QNetworkReply* reply )
{
if( reply->error() == QNetworkReply::NoError )
{
qDebug() << "Size of downloaded file:" << reply->size();
qDebug() << "Size of saved file:" << reply->readAll().length();
}
}

Size of downloaded file: 11902976
Size of saved file: 11894784

Why????