@@ -32,23 +32,23 @@ public async Task<Guid> UploadWholeContentAsync(Guid accountId, Stream stream, T
3232 var response = await contents . StartUploadAsync ( accountId , stream , 0 , stream . Length - 1 , stream . Length , timeout ) . ConfigureAwait ( false ) ;
3333 return response . Id ;
3434 }
35-
36- public async Task < Guid > UploadFirstChunkAsync ( Guid accountId , byte [ ] buffer , long from , long ? totalLength , TimeSpan ? timeout )
35+
36+ public async Task < Guid > UploadFirstChunkAsync ( Guid accountId , byte [ ] buffer , long from , long totalLength , TimeSpan ? timeout )
3737 {
3838 var to = from + buffer . Length - 1 ;
3939 var response = await contents . StartUploadAsync ( accountId , buffer , from , to , totalLength , timeout ) . ConfigureAwait ( false ) ;
4040 return response . Id ;
4141 }
4242
43- public async Task < bool > UploadIntermediateChunkAsync ( Guid accountId , Guid contentId , byte [ ] buffer , long from , long ? totalLength , TimeSpan ? timeout )
43+ public async Task < bool > UploadIntermediateChunkAsync ( Guid accountId , Guid contentId , byte [ ] buffer , long from , long totalLength , TimeSpan ? timeout )
4444 {
4545 var response = await UploadChunkAsync ( accountId , contentId , buffer , from , totalLength , timeout ) . ConfigureAwait ( false ) ;
4646 return response . IsCompleted ;
4747 }
4848
49- private Task < UploadChunkResponse > UploadChunkAsync ( Guid accountId , Guid contentId , byte [ ] buffer , long from , long ? totalLength , TimeSpan ? timeout )
49+ private Task < UploadChunkResponse > UploadChunkAsync ( Guid accountId , Guid contentId , byte [ ] buffer , long from , long totalLength , TimeSpan ? timeout )
5050 {
51- var to = from + buffer . Length - 1 ;
51+ var to = Math . Min ( from + buffer . Length , totalLength ) - 1 ;
5252 return contents . UploadChunkAsync ( accountId , contentId , buffer , from , to , totalLength , timeout ) ;
5353 }
5454 }
0 commit comments