文件目录和下载请求功能自测通过
This commit is contained in:
@@ -327,6 +327,10 @@ std::string G_MQCONSUMER_TOPIC_FILE = "";//consumer topie
|
||||
std::string G_MQCONSUMER_TAG_FILE = "";//consumer tag
|
||||
std::string G_MQCONSUMER_KEY_FILE = "";//consumer key
|
||||
|
||||
std::string G_REPLY_TOPIC_FILE = "";//consumer topie
|
||||
std::string G_REPLY_TAG_FILE = "";//consumer tag
|
||||
std::string G_REPLY_KEY_FILE = "";//consumer key
|
||||
|
||||
std::string G_MQCONSUMER_TOPIC_TEST = "";
|
||||
|
||||
int G_TEST_FLAG = 0;
|
||||
@@ -732,6 +736,12 @@ void init_config() {
|
||||
G_MQCONSUMER_TAG_FILE = strdup(ba.data());
|
||||
ba = settings.value("RocketMq/ConsumerKeyFILE", "").toString().toLatin1();
|
||||
G_MQCONSUMER_KEY_FILE = strdup(ba.data());
|
||||
ba = settings.value("RocketMq/ReplyTopicFILE", "").toString().toLatin1();
|
||||
G_REPLY_TOPIC_FILE = strdup(ba.data());
|
||||
ba = settings.value("RocketMq/ReplyTagFILE", "").toString().toLatin1();
|
||||
G_REPLY_TAG_FILE = strdup(ba.data());
|
||||
ba = settings.value("RocketMq/ReplyKeyFILE", "").toString().toLatin1();
|
||||
G_REPLY_KEY_FILE = strdup(ba.data());
|
||||
|
||||
ba = settings.value("RocketMq/ConsumerTopicTEST", "").toString().toLatin1();
|
||||
G_MQCONSUMER_TOPIC_TEST = strdup(ba.data());
|
||||
@@ -5306,7 +5316,7 @@ std::string base64_encode(const std::string& in) {
|
||||
return out; // 返回编码后的字符串
|
||||
}
|
||||
|
||||
void handleUploadResponse(const std::string& response, char* wavepath) {
|
||||
void handleUploadResponse(const std::string& response, char* wavepath, int type) {
|
||||
|
||||
// 解析 JSON 响应
|
||||
cJSON* json_data = cJSON_Parse(response.c_str());
|
||||
@@ -5354,7 +5364,12 @@ void handleUploadResponse(const std::string& response, char* wavepath) {
|
||||
}
|
||||
|
||||
// 拷贝到 wavepath
|
||||
strcpy(wavepath, nameWithoutExt.c_str());
|
||||
if (type == 1) {
|
||||
strcpy(wavepath, nameWithoutExt.c_str());
|
||||
}
|
||||
else {
|
||||
strcpy(wavepath, name.c_str());
|
||||
}
|
||||
|
||||
std::cout << "wavepath: " << wavepath << std::endl;
|
||||
|
||||
@@ -5428,7 +5443,7 @@ void handleUploadResponse(const std::string& response, char* wavepath) {
|
||||
}*/
|
||||
|
||||
//这是dataform发送方式
|
||||
void SendFileWeb(const std::string& strUrl, const char* localpath, const char* cloudpath, char* wavepath) {
|
||||
void SendFileWeb(const std::string& strUrl, const char* localpath, const char* cloudpath, char* wavepath,int type) {
|
||||
// 初始化 curl
|
||||
CURL* curl = curl_easy_init();
|
||||
if (curl) {
|
||||
@@ -5482,7 +5497,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);
|
||||
} else {
|
||||
std::cout << "http web success, response: " << resPost0 << std::endl;
|
||||
handleUploadResponse(resPost0, wavepath); // 处理响应
|
||||
handleUploadResponse(resPost0, wavepath, type); // 处理响应
|
||||
}
|
||||
|
||||
// 清理
|
||||
@@ -5497,7 +5512,7 @@ void SendFileWeb(const std::string& strUrl, const char* localpath, const char* c
|
||||
void SOEFileWeb(char* localpath,char* cloudpath, char* wavepath)
|
||||
{
|
||||
//示例ip,更换为实际ip即可
|
||||
SendFileWeb(WEB_FILEUPLOAD,localpath,cloudpath,wavepath);
|
||||
SendFileWeb(WEB_FILEUPLOAD,localpath,cloudpath,wavepath,1);
|
||||
}
|
||||
|
||||
void SOEFileWeb_test()
|
||||
@@ -5550,9 +5565,9 @@ int DownloadFileWeb(const std::string& strUrl,
|
||||
|
||||
std::string fullUrl = strUrl;
|
||||
if (fullUrl.find('?') == std::string::npos)
|
||||
fullUrl += "?path=";
|
||||
fullUrl += "?filePath=";
|
||||
else
|
||||
fullUrl += "&path=";
|
||||
fullUrl += "&filePath=";
|
||||
fullUrl += encodedPath;
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, fullUrl.c_str());
|
||||
@@ -5574,12 +5589,14 @@ int DownloadFileWeb(const std::string& strUrl,
|
||||
if (res != CURLE_OK)
|
||||
{
|
||||
std::cerr << "DownloadFileWeb failed: " << curl_easy_strerror(res) << std::endl;
|
||||
remove(localpath);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (http_code != 200)
|
||||
{
|
||||
std::cerr << "DownloadFileWeb http code: " << http_code << std::endl;
|
||||
remove(localpath);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user