Skip to content

Commit 91aef9c

Browse files
Inna-not-botmissLylue
authored andcommitted
Fixed content range header
1 parent 30ccf11 commit 91aef9c

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/Kontur.Extern.Api.Client/Client/Uploading/ContentService.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/Kontur.Extern.Api.Client/Client/Uploading/IContentService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public interface IContentService
1212

1313
Task<Guid> UploadWholeContentAsync(Guid accountId, byte[] buffer, TimeSpan? timeout);
1414
Task<Guid> UploadWholeContentAsync(Guid accountId, Stream stream, TimeSpan? timeout);
15-
Task<Guid> UploadFirstChunkAsync(Guid accountId, byte[] buffer, long from, long? totalLength, TimeSpan? timeout);
16-
Task<bool> UploadIntermediateChunkAsync(Guid accountId, Guid contentId, byte[] buffer, long from, long? totalLength, TimeSpan? timeout);
15+
Task<Guid> UploadFirstChunkAsync(Guid accountId, byte[] buffer, long from, long totalLength, TimeSpan? timeout);
16+
Task<bool> UploadIntermediateChunkAsync(Guid accountId, Guid contentId, byte[] buffer, long from, long totalLength, TimeSpan? timeout);
1717
}
1818
}

0 commit comments

Comments
 (0)