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// 上传文件
3133void 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\n Authorization: %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\n Authorization: %s\r\n " ), tszBaseBuffer);
70+ _stprintf (tszHdrBuffer, _T (" Range: bytes=5-9/10\r\n Authorization: %s\r\n StorageKey: %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 ());
0 commit comments