Your approach should work but it may return a zero byte array under error conditions (you check for neither):
You could also check that the size of the byte array from readAll() is the same size as the p_BytesTotal.This signal is emitted to indicate the progress of the download part of this network request, if there's any. If there's no download associated with this request, this signal will be emitted once with 0 as the value of both bytesReceived and bytesTotal.
You are better off doing this processing in response to a finished() signal after checking QNetworkReply::error() for success. Relying on the system's network buffers to hold the incoming file is probably OK for small files. If the file is particularly large then you could accumulate the response in a QByteArray or temporary file as it arrives using the readyRead() signal and complete processing in when finished() is emitted and no errors are lodged.




Reply With Quote
Bookmarks