1234567891011121314151617181920212223242526272829303132333435363738 |
- #include "StdAfx.h"
- #include "ServerImgDownloadTask.h"
- #include "..\EvaluationUtil\HttpClient.h"
- #include <afx.h>
- CServerImgDownloadTask::CServerImgDownloadTask(const CString &imgpath,const CString & url )
- {
- m_imgpath = imgpath;
- m_url = url;
- }
- CServerImgDownloadTask::~CServerImgDownloadTask(void)
- {
- }
- void CServerImgDownloadTask::Run()
- {
- m_result =false;
- bool succss =false;
- for (int i=0;i<5&&!succss;i++)
- {
- CHttpClient httpClient;
- vector<char> data;
- int ret =httpClient.HttpDownload(m_url,0,data);
- if(ret==CHttpClient::SUCCESS){
- CFile file;
- ret =file.Open(m_imgpath,CFile::OpenFlags::modeCreate|CFile::OpenFlags::modeWrite);
- if(ret){
- file.Write(data.data(),data.size());
- file.Close();
- succss =true;
- m_result =true;
- }
- }
- }
- }
|