remove file after upload
This commit is contained in:
@@ -5332,7 +5332,7 @@ std::string base64_encode(const std::string& in) {
|
|||||||
return out; // 返回编码后的字符串
|
return out; // 返回编码后的字符串
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleUploadResponse(const std::string& response, char* wavepath, int type) {
|
void handleUploadResponse(const std::string& response,const std::string& localPath, char* wavepath, int type) {
|
||||||
|
|
||||||
// 解析 JSON 响应
|
// 解析 JSON 响应
|
||||||
cJSON* json_data = cJSON_Parse(response.c_str());
|
cJSON* json_data = cJSON_Parse(response.c_str());
|
||||||
@@ -5390,6 +5390,33 @@ void handleUploadResponse(const std::string& response, char* wavepath, int type)
|
|||||||
std::cout << "wavepath: " << wavepath << std::endl;
|
std::cout << "wavepath: " << wavepath << std::endl;
|
||||||
|
|
||||||
DIY_INFOLOG_CODE("process",0,LOG_CODE_TRANSIENT_COMM,"【NORMAL】前置上传文件成功,远端文件名:%s",wavepath);
|
DIY_INFOLOG_CODE("process",0,LOG_CODE_TRANSIENT_COMM,"【NORMAL】前置上传文件成功,远端文件名:%s",wavepath);
|
||||||
|
|
||||||
|
// =========================
|
||||||
|
// 上传成功后删除本地文件
|
||||||
|
// =========================
|
||||||
|
if (remove(localPath.c_str()) == 0)
|
||||||
|
{
|
||||||
|
std::cout << "Delete local file success: "
|
||||||
|
<< localPath << std::endl;
|
||||||
|
DIY_INFOLOG_CODE("process",0,
|
||||||
|
LOG_CODE_TRANSIENT_COMM,
|
||||||
|
"【NORMAL】删除本地文件成功:%s",
|
||||||
|
localPath.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "Delete local file failed: "
|
||||||
|
<< localPath
|
||||||
|
<< " errno=" << errno
|
||||||
|
<< " err=" << strerror(errno)
|
||||||
|
<< std::endl;
|
||||||
|
DIY_ERRORLOG_CODE("process",0,
|
||||||
|
LOG_CODE_TRANSIENT_COMM,
|
||||||
|
"【ERROR】删除本地文件失败:%s errno=%d err=%s",
|
||||||
|
localPath.c_str(),
|
||||||
|
errno,
|
||||||
|
strerror(errno));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "Error: Missing expected fields in JSON response." << std::endl;
|
std::cerr << "Error: Missing expected fields in JSON response." << std::endl;
|
||||||
@@ -5513,7 +5540,7 @@ void SendFileWeb(const std::string& strUrl, const char* localpath, const char* c
|
|||||||
DIY_ERRORLOG_CODE("process",0,LOG_CODE_TRANSIENT_COMM,"【ERROR】前置上传暂态录波文件 %s 失败,请检查文件上传接口配置",localpath);
|
DIY_ERRORLOG_CODE("process",0,LOG_CODE_TRANSIENT_COMM,"【ERROR】前置上传暂态录波文件 %s 失败,请检查文件上传接口配置",localpath);
|
||||||
} else {
|
} else {
|
||||||
std::cout << "http web success, response: " << resPost0 << std::endl;
|
std::cout << "http web success, response: " << resPost0 << std::endl;
|
||||||
handleUploadResponse(resPost0, wavepath, type); // 处理响应
|
handleUploadResponse(resPost0, localpath, wavepath, type); // 处理响应
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清理
|
// 清理
|
||||||
|
|||||||
1297
json/PQSMsg.cpp
Normal file
1297
json/PQSMsg.cpp
Normal file
File diff suppressed because it is too large
Load Diff
2548
json/PQSMsg.h
Normal file
2548
json/PQSMsg.h
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user