MCPcopy Create free account
hub / github.com/SmingHub/Sming / downloadFile

Method downloadFile

Sming/Components/Network/src/Network/Http/HttpClient.cpp:49–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49bool HttpClient::downloadFile(const Url& url, const String& saveFileName, RequestCompletedDelegate requestComplete)
50{
51 String file = saveFileName;
52 if(file.length() == 0) {
53 file = url.getFileName();
54 }
55
56 auto fileStream = new FileStream();
57 if(!fileStream->open(file, File::CreateNewAlways | File::WriteOnly)) {
58 debug_e("HttpClient failed to open \"%s\"", file.c_str());
59 delete fileStream;
60 return false;
61 }
62
63 return send(
64 createRequest(url)->setResponseStream(fileStream)->setMethod(HTTP_GET)->onRequestComplete(requestComplete));
65}
66
67void HttpClient::cleanInactive()
68{

Callers 2

downloadContentFilesFunction · 0.45
downloadContentFilesFunction · 0.45

Calls 7

getFileNameMethod · 0.80
onRequestCompleteMethod · 0.80
setResponseStreamMethod · 0.80
lengthMethod · 0.45
openMethod · 0.45
c_strMethod · 0.45
setMethodMethod · 0.45

Tested by

no test coverage detected