C++客户端开发接口库 V5.1.8.15
连接信创集成中间件服务程序的二次开发接口
载入中...
搜索中...
未找到
mdwc::CFileTransferHelper类 参考

#include <FileTransferHelper.h>

Public 成员函数

 CFileTransferHelper (unsigned char uRouteNode=0)
 CFileTransferHelper (CMidLinkComm *MidComm)
 ~CFileTransferHelper ()
void SetProgressCallback (std::function< PPROGRESSCALLBACK > pCallback)
std::string GetLastErrorMessage ()
int GetLastErrorCode ()
int64_t DownLoadFile (const std::string &sLocalFileName, const std::string &sRemoteFileName, bool ResumeBreak, int64_t iFileSize=0, const std::string &sVerifyMD5="", int iDownReqNo=RDMS_DOWNLOADFILE)
int64_t DownLoadFile (const std::string &sRemoteFileName, std::streambuf &sRcvStream, int64_t iFileSize=0, int iDownReqNo=RDMS_DOWNLOADFILE)
std::vector< REMOTE_FILE_INFO > GetServerDirectoryFileInfo (const std::string &sPathName, bool bSearchSubDir=true, bool bCalculateMD5=false, int iDownReqNo=RDMS_GETDIR_FILEINFO)
bool DownloadDirectoryFiles (const std::string &sPathName, const std::string &sSavePathTo, bool bIncludeSubDir=true, int iDownReqNo=RDMS_DOWNLOAD_FLODER)
bool BatchDownLoadFiles (const std::vector< REMOTE_FILE_INFO > &lstFiles, const std::string &sSavePathTo, REMOTE_STORE_TYPE store_type=REMOTE_STORE_TYPE::DAS, bool ResumeBreak=true, const std::string &sSotrePara="", int iDownReqNo=RDMS_BATCHGET_FILES)
int UpLoadFile (const std::string &sLocalFileName, const std::string &sServerSaveFileName, bool ResumeBreak=true, int iUploadReqNo=RDMS_UPLOAD_FILE)
bool UpLoadFileToMidCache (const std::string &sLocalFileName, std::string &sFileMD5, int iUploadReqNo=RDMS_SAVEFILE_CACHE)
int BatchUpLoadFiles (const std::vector< SEND_FILE_INFO > &lstFiles, int iUploadReqNo=RDMS_UPLOAD_FILE, const std::string &sAddToMidFileCache="Auto")
int UpLoadDirectoryFile (const std::string &sLocalPathName, const std::string &sSavePathTo, bool bIncludeSubDir=true, bool ResumeBreak=true, int iUploadReqNo=RDMS_UPLOAD_FILE)
int UpLoadFrontServerFileToRemote (unsigned char uRemoteNode, const std::string &sFSPathName, const std::string &sRSPathName, bool bIncludeSubDir=true, const std::string &sAddToCache="AUTO", int iUploadReqNo=RDMS_UPLOAD_FSFILE)
bool DeleteServerFile (const std::string &sServerFileName, const std::string &sFloderDelteMode="", int iReqNo=RDMS_DELET_FILE)
std::vector< std::string > ReadMTPFile (const std::string &sFileName)

静态 Public 成员函数

static int64_t GetFileMD5 (const std::string &sFileName, std::string &sMD5Value)
static bool GetFileMD5 (const std::string &sFileName, int64_t &iFileSize, std::string &sMD5Value)
static std::string SpeedFormat (int speed)
static std::string TimeFormat (int64_t time, bool bIsMicrosecond=false)

详细描述

文件传送功能,线程不安全,使用完成后必须调用Dispose回收通信连接

构造及析构函数说明

◆ CFileTransferHelper() [1/2]

mdwc::CFileTransferHelper::CFileTransferHelper ( unsigned char uRouteNode = 0)

构造函数,使用完成后必须调用Dispose回收通信连接

参数
uRouteNode数据转到目标节点,为0不转发

◆ CFileTransferHelper() [2/2]

mdwc::CFileTransferHelper::CFileTransferHelper ( CMidLinkComm * MidComm)

构造函数,使用完成后必须调用Dispose回收通信连接

参数
MidComm使用已经分配的通信连接,实例释放时不会从连接池中释放,调用者要处理好多线程使用的冲突和保证释放

◆ ~CFileTransferHelper()

mdwc::CFileTransferHelper::~CFileTransferHelper ( )

析构函数,释放占用的通信连接

成员函数说明

◆ BatchDownLoadFiles()

bool mdwc::CFileTransferHelper::BatchDownLoadFiles ( const std::vector< REMOTE_FILE_INFO > & lstFiles,
const std::string & sSavePathTo,
REMOTE_STORE_TYPE store_type = REMOTE_STORE_TYPE::DAS,
bool ResumeBreak = true,
const std::string & sSotrePara = "",
int iDownReqNo = RDMS_BATCHGET_FILES )

批模式下载文件

参数
lstFiles要下载的文件列表
sSavePathTo保存到本地方文件夹
ResumeBreak文件断点续传,已经存在的文件不传送
store_type服务端文件存储类型
sSotrePara访问文件存储服务的参数,如对象存储接口,FTP服务器连接参数等,格式参数中间件相关文档
iDownReqNo调用的中间件业务脚本号
返回
成功、失败
函数调用图:

◆ BatchUpLoadFiles()

int mdwc::CFileTransferHelper::BatchUpLoadFiles ( const std::vector< SEND_FILE_INFO > & lstFiles,
int iUploadReqNo = RDMS_UPLOAD_FILE,
const std::string & sAddToMidFileCache = "Auto" )

批量上传文件到服务器

参数
lstFiles要上传的文件列表
iUploadReqNo上传文件业务功能号
sAddToMidFileCache是否将文件添加到中间件文件缓存中, 'Auto'表示由中间件服务器确定,'Yes'表示添加,'No'表示不添加
返回
返回成功上传数量
函数调用图:
这是这个函数的调用关系图:

◆ DeleteServerFile()

bool mdwc::CFileTransferHelper::DeleteServerFile ( const std::string & sServerFileName,
const std::string & sFloderDelteMode = "",
int iReqNo = RDMS_DELET_FILE )

删除服务器上的文件

参数
sServerFileName服务器上的文件名
sFloderDelteMode文件夹删除处理模式 "DELDIR"–直接删除整个文件夹 空值–文件夹为空时递归删除 "DIREMPTYNODEL"–文件夹为空时不删除
iReqNo删除文件功能号
返回
成功/失败

◆ DownloadDirectoryFiles()

bool mdwc::CFileTransferHelper::DownloadDirectoryFiles ( const std::string & sPathName,
const std::string & sSavePathTo,
bool bIncludeSubDir = true,
int iDownReqNo = RDMS_DOWNLOAD_FLODER )

下载服务器指定文件夹中文件

参数
sPathName文件夹名称
sSavePathTo保存到本地文件夹
bIncludeSubDir是否包括子文件夹
iDownReqNo
返回
返回文件信息

◆ DownLoadFile() [1/2]

int64_t mdwc::CFileTransferHelper::DownLoadFile ( const std::string & sLocalFileName,
const std::string & sRemoteFileName,
bool ResumeBreak,
int64_t iFileSize = 0,
const std::string & sVerifyMD5 = "",
int iDownReqNo = RDMS_DOWNLOADFILE )

从服务器下载文件保存,支持断点续传

参数
sLocalFileName本地文件名
sRemoteFileName文件名(服务器上、全路径)
ResumeBreak是否使用断点续传
iFileSize要下载的文件尺寸,为0不对尺寸进行检查
sVerifyMD5效验文件下载是否成功的MD5值,为空不进行效验
iDownReqNo下载文件中间件业务功能号
返回
返回文件尺寸
函数调用图:

◆ DownLoadFile() [2/2]

int64_t mdwc::CFileTransferHelper::DownLoadFile ( const std::string & sRemoteFileName,
std::streambuf & sRcvStream,
int64_t iFileSize = 0,
int iDownReqNo = RDMS_DOWNLOADFILE )

从服务器下载文件到内存

参数
sRemoteFileName文件名(服务器上、全路径)
sRcvStream输出已接受的内存流
iFileSize文件大小
iDownReqNo下载文件业务功能号
返回
返回文件尺寸 小于等于 0 表示失败

◆ GetFileMD5() [1/2]

bool mdwc::CFileTransferHelper::GetFileMD5 ( const std::string & sFileName,
int64_t & iFileSize,
std::string & sMD5Value )
static

取得文件的MD5效验值

参数
sFileName文件名, Windows下,调用前转换GBK编码
iFileSize要计算MD5的文件尺寸
sMD5Value返回的MD5效验值
返回
成功、失败

◆ GetFileMD5() [2/2]

int64_t mdwc::CFileTransferHelper::GetFileMD5 ( const std::string & sFileName,
std::string & sMD5Value )
static

取得文件的MD5效验值

参数
sFileName文件名, Windows下,调用前转换GBK编码
sMD5Value返回的MD5效验值
返回
返回文件尺寸,=0 表示文件不存在
这是这个函数的调用关系图:

◆ GetLastErrorCode()

int mdwc::CFileTransferHelper::GetLastErrorCode ( )

取得最后执行的错误代码

返回
返回错误代码

◆ GetLastErrorMessage()

std::string mdwc::CFileTransferHelper::GetLastErrorMessage ( )

取得最后执行的错误信息描述

返回
返回错误信息

◆ GetServerDirectoryFileInfo()

std::vector< mdwc::REMOTE_FILE_INFO > mdwc::CFileTransferHelper::GetServerDirectoryFileInfo ( const std::string & sPathName,
bool bSearchSubDir = true,
bool bCalculateMD5 = false,
int iDownReqNo = RDMS_GETDIR_FILEINFO )

获取服务器指定文件夹中文件信息

参数
sPathName文件夹名称
bSearchSubDir是否搜索子文件夹
bCalculateMD5是否计算文件MD5值,要计算MD5时,文件多,等待时间过长
iDownReqNo取得文件夹信息功能号
返回
返回文件信息

◆ ReadMTPFile()

std::vector< std::string > mdwc::CFileTransferHelper::ReadMTPFile ( const std::string & sFileName)

读取MTP数据文件到vector<std::string>对象

参数
sFileNameMTP文件名
返回
返回数据表对象

◆ SetProgressCallback()

void mdwc::CFileTransferHelper::SetProgressCallback ( std::function< PPROGRESSCALLBACK > pCallback)
inline

设置处理进度回调函数

◆ SpeedFormat()

std::string mdwc::CFileTransferHelper::SpeedFormat ( int speed)
static

格式化传输速度.

参数
speed传输速度,单位为KB/s
这是这个函数的调用关系图:

◆ TimeFormat()

std::string mdwc::CFileTransferHelper::TimeFormat ( int64_t time,
bool bIsMicrosecond = false )
static

格式化传输时间.

参数
time时间值,默认单位为毫秒, bIsMicrosecond=true时间单位为微秒
bIsMicrosecond是否为微秒

◆ UpLoadDirectoryFile()

int mdwc::CFileTransferHelper::UpLoadDirectoryFile ( const std::string & sLocalPathName,
const std::string & sSavePathTo,
bool bIncludeSubDir = true,
bool ResumeBreak = true,
int iUploadReqNo = RDMS_UPLOAD_FILE )

上传本地文件夹中的文件到服务器

参数
sLocalPathName本地文件夹名称
sSavePathTo保存到服务器文件夹
bIncludeSubDir是否包括子文件夹
ResumeBreak文件断点续传,服务端已经存在的文件不传送
iUploadReqNo上传文件业务功能号
返回
返回成功上传数量
函数调用图:

◆ UpLoadFile()

int mdwc::CFileTransferHelper::UpLoadFile ( const std::string & sLocalFileName,
const std::string & sServerSaveFileName,
bool ResumeBreak = true,
int iUploadReqNo = RDMS_UPLOAD_FILE )

上传文件到服务器

参数
sLocalFileName本地文件(全路径)
sServerSaveFileName服务器文件名,如果不含文件名,使用本地文件名
ResumeBreak文件断点续传,已经存在的文件不传送
iUploadReqNo上传文件业务功能号
返回
返回成功上传数量
函数调用图:

◆ UpLoadFileToMidCache()

bool mdwc::CFileTransferHelper::UpLoadFileToMidCache ( const std::string & sLocalFileName,
std::string & sFileMD5,
int iUploadReqNo = RDMS_SAVEFILE_CACHE )

保存文件到中间件服务器文件缓存中

参数
sLocalFileName本地文件(全路径)
sFileMD5本地文件MD5值,为空将自动计算
iUploadReqNo上传文件业务功能号
返回
成功/失败
函数调用图:

◆ UpLoadFrontServerFileToRemote()

int mdwc::CFileTransferHelper::UpLoadFrontServerFileToRemote ( unsigned char uRemoteNode,
const std::string & sFSPathName,
const std::string & sRSPathName,
bool bIncludeSubDir = true,
const std::string & sAddToCache = "AUTO",
int iUploadReqNo = RDMS_UPLOAD_FSFILE )

上传前置中间件服务器上的文件到远程服务器

参数
uRemoteNode远程节点号
sFSPathName前置服务器上可读写的全路径文件名或文件夹
sRSPathName保存到服务器上伯文件名或文件夹
bIncludeSubDir是否上传子文件夹中所有文件
sAddToCache上传后是否添加到中间件文件缓存中,AUTO–服务器开启缓存确定,YES/TRUE–添加,其他值不添加
iUploadReqNo上传文件业务功能号
返回
返回成功上传数量

该类的文档由以下文件生成:
  • E:/GreatMIMP.Linux.Client/MDWClient/FileTransferHelper.h
  • E:/GreatMIMP.Linux.Client/MDWClient/FileTransferHelper.cpp