Train_Identify/nvidia_ascend_engine/common_engine/DataUploadEngine/DataToFtpSrvEngine.h

63 lines
1.8 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 数据(图片等)上传ftp
* */
#ifndef DATATOFTPSRVENGINE_H
#define DATATOFTPSRVENGINE_H
#include "AppCommon.h"
#include "MyYaml.h"
#include "EngineBase.h"
#include "EngineFactory.h"
#include <mutex>
#include <curl/curl.h>
#include <libssh2.h>
#include <libssh2_sftp.h>
#include "json/json.h"
using namespace ai_matrix;
class DataToFtpSrvEngine : public ai_matrix::EngineBase
{
public:
DataToFtpSrvEngine();
~DataToFtpSrvEngine();
APP_ERROR Init() override;
APP_ERROR DeInit() override;
APP_ERROR Process() override;
private:
//将字符串中的特殊字符转换为Ascii值用于防止用户名密码中存在特殊符号
void Symbol2Ascii(std::string &str);
//libcurl回调函数
static size_t ReadCallBack(void* pBbuffer, size_t size, size_t nmemb, FILE* pFile);
//数据上传
bool DataToFtpSrv(Json::Value &jvFtpData);
//处理上传失败的信息
void DealFtpFailInfo();
//保存上传失败的信息
bool SaveFtpFailInfo(Json::Value &jvFtpData, std::string &strFilePath);
std::string strPort0_;
std::string strType_; //ftp或sftp
std::string strIp_; //服务器ip
int iPort_; //服务器端口
std::string strUser_; //用户名
std::string strPwd_; //密码
std::string strImgPath_; //上传到的路径
int iQuitTime_; //无上传任务延迟XXX秒断开FTP连接
std::string strURL_; //上传url
std::string strFailSavePath_; //失败信息保存文件
std::string strFailSaveBakPath_; //失败信息保存文件备份
CURL *pCurl_ = nullptr;
int iNoDataCnt_ = 0;
};
ENGINE_REGIST(DataToFtpSrvEngine)
#endif