mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
http文件下载器改成默认不断点续传
This commit is contained in:
parent
1b78f7ae5a
commit
ebf1c53543
@ -65,9 +65,20 @@ void HttpDownloader::onResponseBody(const char* buf, size_t size, size_t recvedS
|
||||
fwrite(buf,size,1,_saveFile);
|
||||
}
|
||||
}
|
||||
|
||||
//string getMd5Sum(const string &filePath){
|
||||
// auto fp = File::createfile_file(filePath.data(),"rb");
|
||||
// fseek(fp,0,SEEK_END);
|
||||
// auto sz = ftell(fp);
|
||||
// char tmp[sz];
|
||||
// fseek(fp,0,SEEK_SET);
|
||||
// auto rd = fread(tmp,1,sz,fp);
|
||||
// InfoL << sz << " " << rd;
|
||||
// fclose(fp);
|
||||
// return MD5(string(tmp,sz)).hexdigest();
|
||||
//}
|
||||
void HttpDownloader::onResponseCompleted() {
|
||||
closeFile();
|
||||
//InfoL << "md5Sum:" << getMd5Sum(_filePath);
|
||||
_bDownloadSuccess = true;
|
||||
if(_onResult){
|
||||
_onResult(Err_success,"success",_filePath.data());
|
||||
@ -88,6 +99,7 @@ void HttpDownloader::onDisconnect(const SockException &ex) {
|
||||
|
||||
void HttpDownloader::closeFile() {
|
||||
if(_saveFile){
|
||||
fflush(_saveFile);
|
||||
fclose(_saveFile);
|
||||
_saveFile = nullptr;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ public:
|
||||
HttpDownloader();
|
||||
virtual ~HttpDownloader();
|
||||
//开始下载文件,默认断点续传方式下载
|
||||
void startDownload(const string &url,const string &filePath = "",bool bAppend = true);
|
||||
void startDownload(const string &url,const string &filePath = "",bool bAppend = false);
|
||||
void startDownload(const string &url,const onDownloadResult &cb){
|
||||
setOnResult(cb);
|
||||
startDownload(url);
|
||||
|
Loading…
Reference in New Issue
Block a user