PDA

View Full Version : Help with QNetworkAcessaManager download zip file HTTP.



ReDKiiL
22nd March 2015, 16:09
Hi guys.

I am in need of help.

I'm building an application that downloads a file from the web server but precisely a .zip file.
It downloads the file but when I open the file is corrupted.



#include "formpost.h"
#include "ui_formpost.h"
#include "qdebug.h"

FormPost::FormPost(QWidget *parent) :
QWidget(parent),
ui(new Ui::FormPost)
{
ui->setupUi(this);
carregarIpsum();
}

FormPost::~FormPost()
{
delete ui;
}
void FormPost::carregarIpsum(){
netw = new QNetworkAccessManager(this);
connect(netw,SIGNAL(finished(QNetworkReply*)),this ,SLOT(finishedSlot(QNetworkReply*)));
QUrl url("http://192.168.1.2/night/M5.zip");
netw->get(QNetworkRequest(url));
}
void FormPost::finishedSlot(QNetworkReply *reply){
if(reply->error() == QNetworkReply::NoError){
QFile other("Download.zip");
other.open(QIODevice::WriteOnly);
other.write(reply->readAll());
other.flush();
other.close();
}
reply->deleteLater();
}

wysota
22nd March 2015, 17:03
In what way is it corrupted? Is it shorter than you expected?

ReDKiiL
22nd March 2015, 17:18
Sorry,I configured wrong time to compress.
Fixed.

Rajesh.Rathod
9th September 2016, 07:56
I am facing same issue and I didn't understand what was solution here.

Can anyone please explain this solution, how to fix this.

Thanks,

wysota
9th September 2016, 08:11
What exactly is the issue you are facing?

Rajesh.Rathod
9th September 2016, 14:18
its size is 5 byte and 0 byte on disk.

and it shows following message box when tried to open it.

12106

this zip file is password protected and sometimes it also says no archive found.

I am using almost same code mentioned in the first post in this thread.

I can read text file from same web location successfully.

Thanks,

jefftee
10th September 2016, 04:09
I am using almost same code mentioned in the first post in this thread.
Since your code is not the same, please post your code.

Rajesh.Rathod
10th September 2016, 09:28
Finally its working for me, problem was at somewhere else.
Thank you all for your support.

Thanks,