@@ -108,7 +108,7 @@ public HttpResult UploadStream(Stream stream, string key, string upToken, PutExt
108108 {
109109 long uploadedBytes = 0 ;
110110 long fileSize = stream . Length ;
111- int blockCount = ( int ) ( ( fileSize + BLOCK_SIZE - 1 ) / BLOCK_SIZE ) ;
111+ long blockCount = ( fileSize + BLOCK_SIZE - 1 ) / BLOCK_SIZE ;
112112
113113 //check resume record file
114114 ResumeInfo resumeInfo = null ;
@@ -136,7 +136,7 @@ public HttpResult UploadStream(Stream stream, string key, string upToken, PutExt
136136 }
137137
138138 //calc upload progress
139- for ( int blockIndex = 0 ; blockIndex < blockCount ; blockIndex ++ )
139+ for ( long blockIndex = 0 ; blockIndex < blockCount ; blockIndex ++ )
140140 {
141141 string context = resumeInfo . Contexts [ blockIndex ] ;
142142 if ( ! string . IsNullOrEmpty ( context ) )
@@ -152,16 +152,16 @@ public HttpResult UploadStream(Stream stream, string key, string upToken, PutExt
152152 //check not finished blocks to upload
153153 UploadControllerAction upCtrl = putExtra . UploadController ( ) ;
154154 ManualResetEvent manualResetEvent = new ManualResetEvent ( false ) ;
155- Dictionary < int , byte [ ] > blockDataDict = new Dictionary < int , byte [ ] > ( ) ;
156- Dictionary < int , HttpResult > blockMakeResults = new Dictionary < int , HttpResult > ( ) ;
155+ Dictionary < long , byte [ ] > blockDataDict = new Dictionary < long , byte [ ] > ( ) ;
156+ Dictionary < long , HttpResult > blockMakeResults = new Dictionary < long , HttpResult > ( ) ;
157157 Dictionary < string , long > uploadedBytesDict = new Dictionary < string , long > ( ) ;
158158 uploadedBytesDict . Add ( "UploadProgress" , uploadedBytes ) ;
159159 byte [ ] blockBuffer = new byte [ BLOCK_SIZE ] ;
160- for ( int blockIndex = 0 ; blockIndex < blockCount ; blockIndex ++ )
160+ for ( long blockIndex = 0 ; blockIndex < blockCount ; blockIndex ++ )
161161 {
162162 string context = resumeInfo . Contexts [ blockIndex ] ;
163163 if ( string . IsNullOrEmpty ( context ) )
164- {
164+ {
165165 //check upload controller action before each chunk
166166 while ( true )
167167 {
@@ -200,7 +200,7 @@ public HttpResult UploadStream(Stream stream, string key, string upToken, PutExt
200200 {
201201 processMakeBlocks ( blockDataDict , upToken , putExtra , resumeInfo , blockMakeResults , uploadedBytesDict , fileSize ) ;
202202 //check mkblk results
203- foreach ( int blkIndex in blockMakeResults . Keys )
203+ foreach ( int blkIndex in blockMakeResults . Keys )
204204 {
205205 HttpResult mkblkRet = blockMakeResults [ blkIndex ] ;
206206 if ( mkblkRet . Code != 200 )
@@ -292,15 +292,15 @@ public HttpResult UploadStream(Stream stream, string key, string upToken, PutExt
292292 return result ;
293293 }
294294
295- private void processMakeBlocks ( Dictionary < int , byte [ ] > blockDataDict , string upToken ,
296- PutExtra putExtra , ResumeInfo resumeInfo , Dictionary < int , HttpResult > blockMakeResults ,
297- Dictionary < string , long > uploadedBytesDict , long fileSize )
295+ private void processMakeBlocks ( Dictionary < long , byte [ ] > blockDataDict , string upToken ,
296+ PutExtra putExtra , ResumeInfo resumeInfo , Dictionary < long , HttpResult > blockMakeResults ,
297+ Dictionary < string , long > uploadedBytesDict , long fileSize )
298298 {
299299 int taskMax = blockDataDict . Count ;
300300 ManualResetEvent [ ] doneEvents = new ManualResetEvent [ taskMax ] ;
301301 int eventIndex = 0 ;
302302 object progressLock = new object ( ) ;
303- foreach ( int blockIndex in blockDataDict . Keys )
303+ foreach ( long blockIndex in blockDataDict . Keys )
304304 {
305305 //signal task
306306 ManualResetEvent doneEvent = new ManualResetEvent ( false ) ;
@@ -333,9 +333,9 @@ private void MakeBlock(object resumeBlockerObj)
333333 {
334334 ResumeBlocker resumeBlocker = ( ResumeBlocker ) resumeBlockerObj ;
335335 ManualResetEvent doneEvent = resumeBlocker . DoneEvent ;
336- Dictionary < int , HttpResult > blockMakeResults = resumeBlocker . BlockMakeResults ;
336+ Dictionary < long , HttpResult > blockMakeResults = resumeBlocker . BlockMakeResults ;
337337 PutExtra putExtra = resumeBlocker . PutExtra ;
338- int blockIndex = resumeBlocker . BlockIndex ;
338+ long blockIndex = resumeBlocker . BlockIndex ;
339339 HttpResult result = new HttpResult ( ) ;
340340 //check whether to cancel
341341 while ( true )
@@ -353,8 +353,8 @@ private void MakeBlock(object resumeBlockerObj)
353353 result . Code = ( int ) HttpCode . USER_CANCELED ;
354354 result . RefCode = ( int ) HttpCode . USER_CANCELED ;
355355 result . RefText += string . Format ( "[{0}] [ResumableUpload] Info: upload task is aborted, mkblk {1}\n " ,
356- DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss.ffff" ) , blockIndex ) ;
357- blockMakeResults . Add ( blockIndex , result ) ;
356+ DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss.ffff" ) , blockIndex ) ;
357+ blockMakeResults . Add ( blockIndex , result ) ;
358358 return ;
359359 }
360360 else
@@ -365,7 +365,7 @@ private void MakeBlock(object resumeBlockerObj)
365365
366366 byte [ ] blockBuffer = resumeBlocker . BlockBuffer ;
367367 int blockSize = blockBuffer . Length ;
368-
368+
369369 string upToken = resumeBlocker . UploadToken ;
370370 Dictionary < string , long > uploadedBytesDict = resumeBlocker . UploadedBytesDict ;
371371 long fileSize = resumeBlocker . FileSize ;
0 commit comments