@@ -36,6 +36,7 @@ using namespace std;
3636typedef struct
3737{
3838 XENGINE_PROTOCOL_FILE st_ProtocolFile;
39+ CHAR tszBuckKey[128 ];
3940 CHAR tszIPAddr[64 ];
4041}P2PFILE_INFO;
4142
@@ -69,6 +70,7 @@ void P2PParse_List(LPCTSTR lpszMsgBuffer, int nMsgLen, list<P2PFILE_INFO>* pStl_
6970 _tcscpy (st_P2PFile.st_ProtocolFile .tszFileTime , st_JsonArray[i][" tszFileTime" ].asCString ());
7071 _tcscpy (st_P2PFile.st_ProtocolFile .tszFileUser , st_JsonArray[i][" tszFileUser" ].asCString ());
7172 _tcscpy (st_P2PFile.tszIPAddr , st_JsonArray[i][" tszTableName" ].asCString ());
73+ _tcscpy (st_P2PFile.tszBuckKey , st_JsonArray[i][" tszBuckKey" ].asCString ());
7274
7375 pStl_ListFile->push_back (st_P2PFile);
7476 }
@@ -84,9 +86,9 @@ void P2PFile_Create(list<P2PFILE_INFO>* pStl_ListFile, LPCTSTR lpszFile)
8486{
8587 P2PFILE_PIECE* pSt_P2PFile = new P2PFILE_PIECE[pStl_ListFile->size ()];
8688
87- int nPos = 0 ;
89+ __int64x nPos = 0 ;
8890 // 得到每个块大小
89- int nPiece = pStl_ListFile->front ().st_ProtocolFile .nFileSize / pStl_ListFile->size ();
91+ __int64x nPiece = pStl_ListFile->front ().st_ProtocolFile .nFileSize / pStl_ListFile->size ();
9092 // 这是一个简单的分布式块算法示例.怎么做分布式,可以根据自己需求做算法拆解
9193 list<P2PFILE_INFO>::const_iterator stl_ListIterator = pStl_ListFile->begin ();
9294 for (int i = 0 ; stl_ListIterator != pStl_ListFile->end (); stl_ListIterator++, i++)
@@ -97,7 +99,7 @@ void P2PFile_Create(list<P2PFILE_INFO>* pStl_ListFile, LPCTSTR lpszFile)
9799 memset (tszDLUrl, ' \0 ' , sizeof (tszDLUrl));
98100 memset (tszRange, ' \0 ' , sizeof (tszRange));
99101
100- _stprintf (tszDLUrl, _T (" %s/%s/%s" ), stl_ListIterator->tszIPAddr , stl_ListIterator->st_ProtocolFile . tszFilePath + 2 , stl_ListIterator->st_ProtocolFile .tszFileName );
102+ _stprintf (tszDLUrl, _T (" %s/%s/%s" ), stl_ListIterator->tszIPAddr , stl_ListIterator->tszBuckKey , stl_ListIterator->st_ProtocolFile .tszFileName );
101103 // 是否是最后一块
102104 if ((int )pStl_ListFile->size () == (i + 1 ))
103105 {
@@ -168,7 +170,7 @@ int main()
168170 st_JsonRoot[" nMode" ] = 1 ; // 使用P2P下载
169171 st_JsonRoot[" lpszBuckKey" ] = " storagekey2" ;
170172 // st_JsonRoot["lpszFileName"] = "qq.exe";
171- st_JsonRoot[" lpszFileHash" ] = " D41D8CD98F00B204E9801998ECF8427E " ;
173+ st_JsonRoot[" lpszFileHash" ] = " 781E5E245D69B566979B86E28D23F2C7 " ;
172174
173175 if (!APIClient_Http_Request (_T (" POST" ), lpszUrl, st_JsonRoot.toStyledString ().c_str (), &nHTTPCode, &ptszMsgBody, &nBodyLen))
174176 {
0 commit comments