Skip to content

Commit 711a585

Browse files
committed
update:updownload and download example
1 parent b1392c1 commit 711a585

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

XEngine_APPClient/APPClient_Download/APPClient_Download.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ using namespace std;
3333

3434
//需要优先配置XEngine
3535
//WINDOWS使用VS2022 x86 debug 编译
36-
//linux使用下面的命令编译
37-
//g++ -std=c++17 -Wall -g APPClient_Download.cpp -o APPClient_Download.exe -I ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -L /usr/local/lib/XEngine_Release/XEngine_BaseLib -L /usr/local/lib/XEngine_Release/XEngine_NetHelp -L /usr/local/lib/XEngine_Release/XEngine_DownLoad -L /usr/local/lib/XEngine_Release/XEngine_SystemSdk -L ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -lXEngine_BaseLib -lNetHelp_APIHelp -lXEngine_Download -lXEngine_SystemApi -ljsoncpp
36+
//linux::g++ -std=c++17 -Wall -g APPClient_Download.cpp -o APPClient_Download.exe -I ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -L /usr/local/lib/XEngine_Release/XEngine_BaseLib -L /usr/local/lib/XEngine_Release/XEngine_NetHelp -L /usr/local/lib/XEngine_Release/XEngine_DownLoad -L /usr/local/lib/XEngine_Release/XEngine_SystemSdk -L ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -lXEngine_BaseLib -lNetHelp_APIHelp -lXEngine_Download -lXEngine_SystemApi -ljsoncpp
37+
//macos::g++ -std=c++17 -Wall -g APPClient_Download.cpp -o APPClient_Download.exe -I ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -L ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -lXEngine_BaseLib -lNetHelp_APIHelp -lXEngine_Download -lXEngine_SystemApi -ljsoncpp
3838

3939
typedef struct
4040
{

XEngine_APPClient/APPClient_UPDownload/APPClient_UPDownload.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
#pragma comment(lib,"XEngine_Core/XEngine_OPenSsl")
66
#pragma comment(lib,"XEngine_NetHelp/NetHelp_APIHelp")
77
#pragma comment(lib,"Ws2_32")
8+
#pragma comment(lib,"../../XEngine_Source/Debug/jsoncpp")
89
#else
910
#endif
1011
#include <stdio.h>
1112
#include <string.h>
1213
#include <time.h>
1314
#include <list>
15+
#include <json/json.h>
1416
#include <XEngine_Include/XEngine_CommHdr.h>
1517
#include <XEngine_Include/XEngine_Types.h>
1618
#include <XEngine_Include/XEngine_ProtocolHdr.h>
@@ -24,8 +26,8 @@ using namespace std;
2426

2527
//需要优先配置XEngine
2628
//WINDOWS使用VS2022 x86 debug 编译
27-
//linux使用下面的命令编译
28-
//g++ -std=c++17 -Wall -g APPClient_UPDownload.cpp -o APPClient_UPDownload.exe -L /usr/local/lib/XEngine_Release/XEngine_BaseLib -L /usr/local/lib/XEngine_Release/XEngine_Core -L /usr/local/lib/XEngine_Release/XEngine_NetHelp -lXEngine_BaseLib -lXEngine_OPenSsl -lNetHelp_APIHelp
29+
//linux::g++ -std=c++17 -Wall -g APPClient_UPDownload.cpp -o APPClient_UPDownload.exe -I ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -L /usr/local/lib/XEngine_Release/XEngine_BaseLib -L /usr/local/lib/XEngine_Release/XEngine_Core -L /usr/local/lib/XEngine_Release/XEngine_NetHelp -L ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -lXEngine_BaseLib -lXEngine_OPenSsl -lNetHelp_APIHelp -ljsoncpp
30+
//macos::g++ -std=c++17 -Wall -g APPClient_UPDownload.cpp -o APPClient_UPDownload.exe -I ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -L ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -lXEngine_BaseLib -lXEngine_OPenSsl -lNetHelp_APIHelp -ljsoncpp
2931

3032
//上传文件
3133
void File_UPLoad()
@@ -36,11 +38,13 @@ void File_UPLoad()
3638
TCHAR* ptszMsgBuffer = NULL;
3739
TCHAR tszBaseBuffer[128];
3840
TCHAR tszHdrBuffer[MAX_PATH];
41+
TCHAR tszKeyBuffer[MAX_PATH];
3942
LPCTSTR lpszMsgBuffer = _T("01234");
4043
LPCTSTR lpszMsgBuffer2 = _T("56789");
4144

4245
memset(tszBaseBuffer, '\0', sizeof(tszBaseBuffer));
4346
memset(tszHdrBuffer, '\0', MAX_PATH);
47+
memset(tszKeyBuffer, '\0', MAX_PATH);
4448
OPenSsl_Help_BasicEncoder("123123aa", "123123", tszBaseBuffer);
4549

4650
_stprintf(tszHdrBuffer, _T("Range: bytes=0-5/10\r\nAuthorization: %s\r\n"), tszBaseBuffer);
@@ -49,11 +53,21 @@ void File_UPLoad()
4953
printf("upload failed:%lX\n", APIHelp_GetLastError());
5054
return;
5155
}
56+
JSONCPP_STRING st_JsonError;
57+
Json::Value st_JsonRoot;
58+
Json::CharReaderBuilder st_JsonBuilder;
59+
std::unique_ptr<Json::CharReader> const pSt_JsonReader(st_JsonBuilder.newCharReader());
60+
if (!pSt_JsonReader->parse(ptszMsgBuffer, ptszMsgBuffer + nLen, &st_JsonRoot, &st_JsonError))
61+
{
62+
return;
63+
}
64+
_tcscpy(tszKeyBuffer, st_JsonRoot["lpszBuckKey"].asCString());
65+
5266
printf("upload:%d\n", nCode);
5367
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer);
54-
68+
//断点续传必须指定storagekey
5569
memset(tszHdrBuffer, '\0', MAX_PATH);
56-
_stprintf(tszHdrBuffer, _T("Range: bytes=5-9/10\r\nAuthorization: %s\r\n"), tszBaseBuffer);
70+
_stprintf(tszHdrBuffer, _T("Range: bytes=5-9/10\r\nAuthorization: %s\r\nStorageKey: %s\r\n"), tszBaseBuffer, tszKeyBuffer);
5771
if (!APIHelp_HttpRequest_Post(lpszUrl, lpszMsgBuffer2, &nCode, &ptszMsgBuffer, &nLen, tszHdrBuffer))
5872
{
5973
printf("upload failed:%lX\n", APIHelp_GetLastError());

XEngine_APPClient/APPClient_UPDownload/APPClient_UPDownload.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
<PropertyGroup Label="UserMacros" />
7373
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
7474
<LinkIncremental>true</LinkIncremental>
75-
<IncludePath>$(XEngine_Include);$(IncludePath)</IncludePath>
75+
<IncludePath>$(XEngine_Include);../../XEngine_Source/XEngine_ThirdPart/jsoncpp;$(IncludePath)</IncludePath>
7676
<LibraryPath>$(XEngine_Lib32);$(LibraryPath)</LibraryPath>
7777
</PropertyGroup>
7878
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">

0 commit comments

Comments
 (0)