Good Day!
I am using the following code to download zip files from a url. The only thing
that changes is the “id” in the url(one for each zip). Anyway, the code always
works on one of the zip files, but never works on the other. Both zips are on
the server. Both zips are downloadable, if I access the url(s) from a web
browser. What I am looking for is primarily direction on how to go about
effectively debugging this. I tried using reply->errorString() right after
loop.exec() — but it returns only “Unknown Error” whether the download is
successful or not. It should also be noted that on failure a file is created
but is not a readable zip file.
Thanks!
void downloadFile(QUrl url, QString filename)
{
QNetworkAccessManager* netManager = new QNetworkAccessManager();
QNetworkRequest request(url);
QNetworkReply* reply = netManager->get(request);
QEventLoop loop;
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
QFile file(filename);
file.open(QIODevice::WriteOnly);
file.write(reply->readAll());
file.close();
netManager->deleteLater();
reply->deleteLater();
}
//--------------------------------//
Jason R. Kretzer
Lead Application Developer
[email protected]
606.792.0079
//--------------------------------//
_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest