Skip to content

Commit 1611d42

Browse files
committed
supported nginx file rename of upload
supported nginx upfile insert to database
1 parent 8b72c9c commit 1611d42

File tree

8 files changed

+29
-9
lines changed

8 files changed

+29
-9
lines changed

XEngine_Docment/Docment_en.docx

193 KB
Binary file not shown.

XEngine_Docment/Docment_zh.docx

104 KB
Binary file not shown.

XEngine_Release/XEngine_Config/XEngine_Config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"XStorage": {
3434
"nUseMode": 1,
3535
"nHashMode": 2,
36+
"bRename": 0,
3637
"tszHttpAddr": "http://192.168.1.4",
3738
"tszNginAddr": "http://192.168.1.4:5010",
3839
"tszFileDir": "./XEngine_File"

XEngine_SQLFile/XEngine.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
Target Server Version : 80025
1212
File Encoding : 65001
1313
14-
Date: 10/06/2021 14:42:39
14+
Date: 17/06/2021 17:19:26
1515
*/
1616

1717
SET NAMES utf8mb4;

XEngine_SQLFile/XEngine_Storage.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
Target Server Version : 80025
1212
File Encoding : 65001
1313
14-
Date: 10/06/2021 14:42:32
14+
Date: 17/06/2021 17:19:07
1515
*/
1616

1717
SET NAMES utf8mb4;
@@ -30,6 +30,6 @@ CREATE TABLE `XStorage_File` (
3030
`FileSize` bigint NOT NULL COMMENT '文件大小',
3131
`FileTime` datetime NOT NULL COMMENT '插入时间',
3232
PRIMARY KEY (`ID`) USING BTREE
33-
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;
33+
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;
3434

3535
SET FOREIGN_KEY_CHECKS = 1;

XEngine_Source/StorageModule_Config/Config_Define.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ typedef struct tag_XEngine_ServerConfig
5353
}st_XSql;
5454
struct
5555
{
56+
BOOL bRename;
5657
int nUseMode;
5758
int nHashMode;
5859
TCHAR tszHttpAddr[MAX_PATH];

XEngine_Source/StorageModule_Config/Config_Json/Config_Json.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ BOOL CConfig_Json::Config_Json_File(LPCTSTR lpszConfigFile,XENGINE_SERVERCONFIG
119119
_tcscpy(pSt_ServerConfig->st_XSql.tszSQLUser,st_JsonXSql["SQLUser"].asCString());
120120
_tcscpy(pSt_ServerConfig->st_XSql.tszSQLPass,st_JsonXSql["SQLPass"].asCString());
121121

122-
if (st_JsonRoot["XStorage"].empty() || (5 != st_JsonRoot["XStorage"].size()))
122+
if (st_JsonRoot["XStorage"].empty() || (6 != st_JsonRoot["XStorage"].size()))
123123
{
124124
Config_IsErrorOccur = TRUE;
125125
Config_dwErrorCode = ERROR_XENGINE_BLOGIC_CONFIG_JSON_XSTORAGE;
@@ -128,6 +128,7 @@ BOOL CConfig_Json::Config_Json_File(LPCTSTR lpszConfigFile,XENGINE_SERVERCONFIG
128128
Json::Value st_JsonXStorage = st_JsonRoot["XStorage"];
129129
pSt_ServerConfig->st_XStorage.nUseMode = st_JsonXStorage["nUseMode"].asInt();
130130
pSt_ServerConfig->st_XStorage.nHashMode = st_JsonXStorage["nHashMode"].asInt();
131+
pSt_ServerConfig->st_XStorage.bRename = st_JsonXStorage["bRename"].asInt();
131132
_tcscpy(pSt_ServerConfig->st_XStorage.tszHttpAddr, st_JsonXStorage["tszHttpAddr"].asCString());
132133
_tcscpy(pSt_ServerConfig->st_XStorage.tszNginAddr, st_JsonXStorage["tszNginAddr"].asCString());
133134
_tcscpy(pSt_ServerConfig->st_XStorage.tszFileDir, st_JsonXStorage["tszFileDir"].asCString());

XEngine_Source/XEngine_StorageApp/StorageApp_Center.cpp

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,15 @@ BOOL XEngine_Task_HttpCenter(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int
147147
LPCTSTR lpszBoundaryStr = _T("boundary=");
148148
TCHAR tszContentStr[MAX_PATH];
149149
TCHAR tszBoundarTmp[MAX_PATH];
150-
TCHAR tszBoundarStr[MAX_PATH];
151150
TCHAR tszFileDir[MAX_PATH];
151+
TCHAR tszBoundarStr[512];
152152
XSTORAGECORE_DBFILE st_DBFile;
153153

154154
memset(tszContentStr, '\0', MAX_PATH);
155155
memset(tszBoundarTmp, '\0', MAX_PATH);
156-
memset(tszBoundarStr, '\0', MAX_PATH);
157156
memset(tszContentStr, '\0', MAX_PATH);
158157
memset(tszFileDir, '\0', MAX_PATH);
158+
memset(tszBoundarStr, '\0', sizeof(tszBoundarStr));
159159
memset(&st_DBFile, '\0', sizeof(XSTORAGECORE_DBFILE));
160160

161161
if (!RfcComponents_HttpHelp_GetField(&pptszListHdr, nHdrCount, lpszContentType, tszContentStr))
@@ -179,10 +179,19 @@ BOOL XEngine_Task_HttpCenter(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int
179179
return FALSE;
180180
}
181181
_stprintf(tszBoundarStr, _T("--%s\r\n"), tszBoundarTmp);
182-
183182
XStorageProtocol_Core_REQUPEvent(lpszMsgBuffer, tszBoundarStr, st_DBFile.st_ProtocolFile.tszFileName, tszFileDir, st_DBFile.st_ProtocolFile.tszFileHash, &st_DBFile.st_ProtocolFile.nFileSize);
184-
_tcscpy(st_DBFile.st_ProtocolFile.tszFilePath, st_ServiceCfg.st_XStorage.tszFileDir);
185-
183+
184+
if (st_ServiceCfg.st_XStorage.bRename)
185+
{
186+
memset(st_DBFile.st_ProtocolFile.tszFilePath, '\0', MAX_PATH);
187+
_tcscpy(st_DBFile.st_ProtocolFile.tszFilePath, st_ServiceCfg.st_XStorage.tszFileDir);
188+
}
189+
else
190+
{
191+
memset(st_DBFile.st_ProtocolFile.tszFileName, '\0', MAX_PATH);
192+
BaseLib_OperatorString_GetFileAndPath(tszFileDir, st_DBFile.st_ProtocolFile.tszFilePath, st_DBFile.st_ProtocolFile.tszFileName);
193+
st_DBFile.st_ProtocolFile.tszFilePath[_tcslen(st_DBFile.st_ProtocolFile.tszFilePath) - 1] = '\0';
194+
}
186195
if (XStorageSQL_File_FileInsert(&st_DBFile))
187196
{
188197
st_HDRParam.nHttpCode = 200;
@@ -197,6 +206,14 @@ BOOL XEngine_Task_HttpCenter(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int
197206
XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_HTTPCENTER);
198207
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("业务客户端:%s,处理NGINX代理上传文件失败,插入数据库失败:%s,错误:%lX"), lpszClientAddr, tszFileDir, XStorageDB_GetLastError());
199208
}
209+
if (st_ServiceCfg.st_XStorage.bRename)
210+
{
211+
TCHAR tszFileTmp[1024];
212+
memset(tszFileTmp, '\0', sizeof(tszFileTmp));
213+
214+
_stprintf(tszFileTmp, _T("%s/%s"), st_DBFile.st_ProtocolFile.tszFilePath, st_DBFile.st_ProtocolFile.tszFileName);
215+
_trename(tszFileDir, tszFileTmp);
216+
}
200217
}
201218
}
202219
return TRUE;

0 commit comments

Comments
 (0)