Skip to content

Commit ac95ebf

Browse files
committed
download and uploader support get bucket for distributed
1 parent 0574515 commit ac95ebf

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

XEngine_Source/XEngine_StorageApp/StorageApp_Download.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,15 @@ BOOL XEngine_Task_HttpDownload(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, in
166166
nPosEnd = 0;
167167
}
168168
}
169-
_stprintf(tszFileDir, _T("%s%s"), st_ServiceCfg.st_XStorage.tszFileDir, pSt_HTTPParam->tszHttpUri);
169+
XENGINE_STORAGEBUCKET st_StorageBucket;
170+
memset(&st_StorageBucket, '\0', sizeof(XENGINE_STORAGEBUCKET));
171+
172+
if (!APIHelp_Distributed_DLStorage(pSt_HTTPParam->tszHttpUri, st_LoadbalanceCfg.st_LoadBalance.pStl_ListBucket, &st_StorageBucket))
173+
{
174+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("下载客户端:%s,请求文件失败,可能BUCKET:% 不正确,错误:%lX"), lpszClientAddr, pSt_HTTPParam->tszHttpUri, APIHelp_GetLastError());
175+
return FALSE;
176+
}
177+
_stprintf(tszFileDir, _T("%s%s"), st_StorageBucket.tszFilePath, st_StorageBucket.tszFileName);
170178

171179
int nHashLen = 0;
172180
UCHAR tszHashKey[MAX_PATH];

XEngine_Source/XEngine_StorageApp/StorageApp_UPLoader.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,15 @@ BOOL XEngine_Task_HttpUPLoader(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, in
9494
int nRVMode = 0;
9595
int nRVCount = 0;
9696
int nHDSize = 0;
97-
_stprintf(tszFileDir, _T("%s%s"), st_ServiceCfg.st_XStorage.tszFileDir, pSt_HTTPParam->tszHttpUri);
97+
XENGINE_STORAGEBUCKET st_StorageBucket;
98+
memset(&st_StorageBucket, '\0', sizeof(XENGINE_STORAGEBUCKET));
99+
100+
if (!APIHelp_Distributed_UPStorage(st_LoadbalanceCfg.st_LoadBalance.pStl_ListBucket, &st_StorageBucket))
101+
{
102+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("上传客户端:%s,请求上传文件失败,可能BUCKET:% 不正确,错误:%lX"), lpszClientAddr, pSt_HTTPParam->tszHttpUri, APIHelp_GetLastError());
103+
return FALSE;
104+
}
105+
_stprintf(tszFileDir, _T("%s%s"), st_StorageBucket.tszFilePath, st_StorageBucket.tszFileName);
98106

99107
if (!Session_UPStroage_Exist(lpszClientAddr))
100108
{
@@ -163,8 +171,7 @@ BOOL XEngine_Task_HttpUPLoader(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, in
163171
memset(tszHashStr, '\0', MAX_PATH);
164172
memset(&st_ProtocolFile, '\0', sizeof(XSTORAGECORE_DBFILE));
165173

166-
_stprintf(tszFileDir, _T("%s%s"), st_ServiceCfg.st_XStorage.tszFileDir, pSt_HTTPParam->tszHttpUri);
167-
_tcscpy(st_ProtocolFile.st_ProtocolFile.tszFilePath, st_ServiceCfg.st_XStorage.tszFileDir);
174+
_tcscpy(st_ProtocolFile.st_ProtocolFile.tszFilePath, st_StorageBucket.tszFilePath);
168175
_tcscpy(st_ProtocolFile.st_ProtocolFile.tszFileName, pSt_HTTPParam->tszHttpUri + 1);
169176
st_ProtocolFile.st_ProtocolFile.nFileSize = nRVCount;
170177

@@ -240,7 +247,6 @@ BOOL XEngine_Task_HttpUPLoader(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, in
240247
}
241248
else
242249
{
243-
_stprintf(tszFileDir, _T("%s%s"), st_ServiceCfg.st_XStorage.tszFileDir, pSt_HTTPParam->tszHttpUri);
244250
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_DEBUG, _T("上传客户端:%s,请求上传文件中,文件名:%s,大小:%d"), lpszClientAddr, tszFileDir, nMsgLen);
245251
}
246252

0 commit comments

Comments
 (0)