Skip to content

Commit a75fc4c

Browse files
authored
Merge pull request #18 from libxengine/develop
V3.4Merge
2 parents 1445628 + b7c8614 commit a75fc4c

File tree

72 files changed

+2779
-1563
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2779
-1563
lines changed

README.en.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ c c++ 存储服务 c c++ 文件存储服务
77
c c++ file storage service
88
This is an api gateway for uploading and downloading.
99
The service is for users who have business needs for upload and download services (such as developers who need to upload and download servers).
10-
This server is more inclined to store the API interface direction
11-
best storage service for http,batter than nginx and more convenient to manage. On going maintenance
10+
This server is more inclined to storestorage transfer and API Manage interface
11+
best storage service for http,batter than nginx and more convenient to manage,more concise code. On going maintenance
1212

1313
## Software feature
1414
The purpose of development and implementation based on libXEngine is a cross-platform network storage service
@@ -97,7 +97,6 @@ P2P distributed download is the same as the hyper-threaded download of other dow
9797

9898
## now task
9999
P2P WAN file search and download support
100-
upload file code optimization
101100

102101
## other problems
103102
You can refer to the document under the docment directory. It contains API protocol and service description.

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ c c++ 存储服务 c c++ 文件存储服务
77
c c++ file storage service
88
这是一个上传下载服务API网关,不是文件同步服务,也不是云存储.
99
这个服务的主要目的是为了给有上传下载服务业务需求的用户使用(比如需要开发上传下载服务的开发人员).
10-
此服务器更偏向于存储API接口方向.
11-
目前最好的HTTP存储服务,比NGINX更优秀,更方便管理.持续维护中...
10+
此服务器更偏向于存储传输与API接口管理.
11+
目前最好的HTTP存储服务,比NGINX更优秀,更方便管理,代码更简洁.持续维护中...
1212

1313
## 软件特性
1414
基于libXEngine开发并实现的一套简洁高性能跨平台网络存储服务
@@ -95,7 +95,6 @@ P2P分布式下载与其他下载工具的超线程下载一样,原理是使用H
9595

9696
## 当前任务
9797
P2P广域网文件查找与下载支持
98-
文件上传代码优化
9998

10099
## 其他问题
101100
你可以参考docment目录下的文档.里面包含了API协议和服务说明.

XEngine_APPClient/APPClient_Download/APPClient_Download.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,14 @@ int main()
155155
int nBodyLen = 2048;
156156
TCHAR *ptszMsgBody = NULL;
157157
//请求分布式存储文件所有位置
158-
LPCTSTR lpszUrl = _T("http://127.0.0.1:5100/7D54D6E40367F2763B8C8056EADC517F");
158+
LPCTSTR lpszUrl = _T("http://127.0.0.1:5100/Api/Manage/P2P");
159159
LPCTSTR lpszFile = _T("D:\\XEngine_Storage\\XEngine_APPClient\\Debug\\qq.exe");
160160

161-
if (!APIHelp_HttpRequest_Get(lpszUrl, &ptszMsgBody, &nBodyLen, &nHTTPCode))
161+
Json::Value st_JsonRoot;
162+
st_JsonRoot["lpszBuckKey"] = "storagekey2";
163+
st_JsonRoot["lpszFileHash"] = "781E5E245D69B566979B86E28D23F2C7";
164+
165+
if (!APIHelp_HttpRequest_Post(lpszUrl, st_JsonRoot.toStyledString().c_str(), &nHTTPCode, &ptszMsgBody, &nBodyLen))
162166
{
163167
return -1;
164168
}

XEngine_APPClient/APPClient_P2XPClient/APPClient_P2XPClient.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ SOCKET m_hSocket;
3333

3434
int APPClient_P2XPLogin()
3535
{
36-
DWORD dwNetType = 0;
3736
Json::Value st_JsonRoot;
3837
TCHAR tszMsgBuffer[2048];
3938
XENGINE_PROTOCOLHDR st_ProtocolHdr;
39+
ENUM_XENGINE_NETXAPI_SOCKET_CONNECTTYPE dwNetType;
4040

4141
memset(tszPublicAddr, '\0', sizeof(tszPublicAddr));
4242
memset(tszPrivateAddr, '\0', sizeof(tszPrivateAddr));
@@ -45,7 +45,7 @@ int APPClient_P2XPLogin()
4545

4646
st_ProtocolHdr.wHeader = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_HEADER;
4747
st_ProtocolHdr.unOperatorType = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_P2XP;
48-
st_ProtocolHdr.unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_AUTH_REQLOGIN;
48+
st_ProtocolHdr.unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_P2XP_REQLOGIN;
4949
st_ProtocolHdr.byVersion = 2;
5050
st_ProtocolHdr.wTail = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_TAIL;
5151

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
#ifdef _WINDOWS
2+
#include <windows.h>
3+
#include <tchar.h>
4+
#include <json/json.h>
5+
#pragma comment(lib,"XEngine_BaseLib/XEngine_BaseLib")
6+
#pragma comment(lib,"XEngine_NetHelp/NetHelp_APIHelp")
7+
#pragma comment(lib,"Ws2_32")
8+
#else
9+
#ifdef _CENTOS
10+
#include <json/json.h>
11+
#else
12+
#include <jsoncpp/json/json.h>
13+
#endif
14+
#endif
15+
#include <stdio.h>
16+
#include <string.h>
17+
#include <time.h>
18+
#include <list>
19+
#include <XEngine_Include/XEngine_CommHdr.h>
20+
#include <XEngine_Include/XEngine_Types.h>
21+
#include <XEngine_Include/XEngine_ProtocolHdr.h>
22+
#include <XEngine_Include/XEngine_BaseLib/BaseLib_Define.h>
23+
#include <XEngine_Include/XEngine_BaseLib/BaseLib_Error.h>
24+
#include <XEngine_Include/XEngine_NetHelp/APIHelp_Define.h>
25+
#include <XEngine_Include/XEngine_NetHelp/APIHelp_Error.h>
26+
using namespace std;
27+
28+
//g++ -std=c++17 -Wall -g APPClient_RestApi.cpp -o APPClient_RestApi.exe -L ../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_BaseLib -L ../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_NetHelp -lXEngine_BaseLib -lNetHelp_APIHelp -ljsoncpp -Wl,-rpath=../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_BaseLib:../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_NetHelp,--disable-new-dtags
29+
30+
//查询
31+
void API_Manage_Query()
32+
{
33+
LPCTSTR lpszUrl = _T("http://192.168.1.8:5100/Api/Manage/QueryFile");
34+
int nLen = 0;
35+
int nCode = 0;
36+
TCHAR* ptszMsgBuffer = NULL;
37+
Json::Value st_JsonRoot;
38+
st_JsonRoot["lpszTimeStart"];
39+
st_JsonRoot["lpszTimeEnd"];
40+
st_JsonRoot["lpszBuckKey"] = "storagekey2";
41+
42+
if (!APIHelp_HttpRequest_Post(lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen))
43+
{
44+
printf("API_Manage_Query:%lX\n", APIHelp_GetLastError());
45+
return;
46+
}
47+
printf("API_Manage_Query:%d,%s\n", nCode, ptszMsgBuffer);
48+
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer);
49+
}
50+
//插入
51+
void API_Manage_Insert()
52+
{
53+
LPCTSTR lpszUrl = _T("http://192.168.1.8:5100/Api/Manage/Insert");
54+
int nLen = 0;
55+
int nCode = 0;
56+
TCHAR* ptszMsgBuffer = NULL;
57+
Json::Value st_JsonRoot;
58+
Json::Value st_JsonArray;
59+
Json::Value st_JsonObject;
60+
61+
st_JsonObject["nFileSize"] = 10;
62+
st_JsonObject["tszFileHash"] = "85E62C9D28FCE775A68DD126E0519F25";
63+
st_JsonObject["tszFileName"] = "2.txt";
64+
st_JsonObject["tszBuckKey"] = "storagekey2";
65+
st_JsonArray.append(st_JsonObject);
66+
67+
st_JsonRoot["List"] = st_JsonArray;
68+
st_JsonRoot["Count"] = 1;
69+
70+
if (!APIHelp_HttpRequest_Post(lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen))
71+
{
72+
printf("API_Manage_Insert:%lX\n", APIHelp_GetLastError());
73+
return;
74+
}
75+
printf("API_Manage_Insert:%d,%s\n", nCode, ptszMsgBuffer);
76+
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer);
77+
}
78+
//删除
79+
void API_Manage_Delete()
80+
{
81+
LPCTSTR lpszUrl = _T("http://192.168.1.8:5100/Api/Manage/Delete");
82+
int nLen = 0;
83+
int nCode = 0;
84+
TCHAR* ptszMsgBuffer = NULL;
85+
Json::Value st_JsonRoot;
86+
Json::Value st_JsonArray;
87+
Json::Value st_JsonObject;
88+
89+
st_JsonObject["tszFileHash"] = "85E62C9D28FCE775A68DD126E0519F25";
90+
st_JsonArray.append(st_JsonObject);
91+
92+
st_JsonRoot["List"] = st_JsonArray;
93+
st_JsonRoot["Count"] = 1;
94+
95+
if (!APIHelp_HttpRequest_Post(lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen))
96+
{
97+
printf("API_Manage_Delete:%lX\n", APIHelp_GetLastError());
98+
return;
99+
}
100+
printf("API_Manage_Delete:%d,%s\n", nCode, ptszMsgBuffer);
101+
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer);
102+
}
103+
//文件夹
104+
void API_Manage_Dir()
105+
{
106+
LPCTSTR lpszUrl = _T("http://192.168.1.8:5100/Api/Manage/Dir");
107+
int nLen = 0;
108+
int nCode = 0;
109+
TCHAR* ptszMsgBuffer = NULL;
110+
Json::Value st_JsonRoot;
111+
//创建
112+
st_JsonRoot["lpszBuckKey"] = "storagekey1";
113+
st_JsonRoot["lpszUserDir"] = "user";
114+
st_JsonRoot["nOPerator"] = 1;
115+
if (!APIHelp_HttpRequest_Post(lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen))
116+
{
117+
printf("API_Manage_Dir:%lX\n", APIHelp_GetLastError());
118+
return;
119+
}
120+
printf("API_Manage_Dir:%d,%s\n", nCode, ptszMsgBuffer);
121+
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer);
122+
//查询
123+
st_JsonRoot.clear();
124+
st_JsonRoot["lpszBuckKey"] = "storagekey1";
125+
st_JsonRoot["lpszUserDir"];
126+
st_JsonRoot["nOPerator"] = 0;
127+
if (!APIHelp_HttpRequest_Post(lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen))
128+
{
129+
printf("API_Manage_Dir:%lX\n", APIHelp_GetLastError());
130+
return;
131+
}
132+
printf("API_Manage_Dir:%d,%s\n", nCode, ptszMsgBuffer);
133+
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer);
134+
//删除
135+
st_JsonRoot.clear();
136+
st_JsonRoot["lpszBuckKey"] = "storagekey1";
137+
st_JsonRoot["lpszUserDir"] = "user";
138+
st_JsonRoot["nOPerator"] = 2;
139+
if (!APIHelp_HttpRequest_Post(lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen))
140+
{
141+
printf("API_Manage_Dir:%lX\n", APIHelp_GetLastError());
142+
return;
143+
}
144+
printf("API_Manage_Dir:%d,%s\n", nCode, ptszMsgBuffer);
145+
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer);
146+
}
147+
//任务管理
148+
void API_Manage_Task()
149+
{
150+
LPCTSTR lpszUrl = _T("http://192.168.1.8:5100/Api/Manage/Task");
151+
int nLen = 0;
152+
int nCode = 0;
153+
TCHAR* ptszMsgBuffer = NULL;
154+
if (!APIHelp_HttpRequest_Post(lpszUrl, NULL, &nCode, &ptszMsgBuffer, &nLen))
155+
{
156+
printf("API_Manage_Task:%lX\n", APIHelp_GetLastError());
157+
return;
158+
}
159+
printf("API_Manage_Task:%d,%s\n", nCode, ptszMsgBuffer);
160+
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer);
161+
}
162+
163+
int main()
164+
{
165+
#ifdef _WINDOWS
166+
WSADATA st_WSAData;
167+
WSAStartup(MAKEWORD(2, 2), &st_WSAData);
168+
#endif
169+
170+
API_Manage_Query();
171+
API_Manage_Insert();
172+
API_Manage_Delete();
173+
API_Manage_Dir();
174+
API_Manage_Task();
175+
#ifdef _WINDOWS
176+
WSACleanup();
177+
#endif
178+
return 0;
179+
}

0 commit comments

Comments
 (0)