Open pigLoveRabbit520 opened 2 years ago
Use wxWebRequest
if you need to just download the files, it's much more feature-rich and almost surely much faster than wx socket streams.
ok
So what is the best practice to notify outside function?
My download
function is here:
wxWebRequest request = wxWebSession::GetDefault().CreateRequest(this, remoteFile);
Bind(wxEVT_WEBREQUEST_STATE, [localZipFile](wxWebRequestEvent& evt) {
switch (evt.GetState())
{
// Request completed
case wxWebRequest::State_Completed:
{
wxFileOutputStream outFile(localZipFile);
wxInputStream* in = evt.GetResponse().GetStream();
if (in && in->IsOk())
{
wxFileOutputStream outFile(localZipFile);
outFile.Write(*in);
}
delete in;
break;
}
// Request failed
case wxWebRequest::State_Failed:
.....
break;
}
});
request.Start();
request.Start()
is async, so how to await the downloading task? There are too little tutorials about wxWidgets.
JFYI, GIT Issues are not for asking questions about user code, they are for reporting bugs or proposing enhancements to wxWidgets.
Use one of wx-users, wxForum, StackOverflow or similar for questions like this...
BTW, did you check the bundled webrequest sample, which also shows how to download a file?
@PBfordev thks.
My
remoteFile
is using cdn, I can download it soon in the browser. However, I have to wait about a minute in wxWidgets.Platform and version information