Skip to content

Commit

Permalink
Merge pull request #93 from mfilippov/long-files-upload
Browse files Browse the repository at this point in the history
Fix upload long files. #79
  • Loading branch information
mfilippov authored Aug 24, 2017
2 parents c902b6f + 9a8cf57 commit f173851
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/VimeoDotNet/VimeoClient_Upload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,7 @@ public async Task<IUploadRequest> UploadEntireFileAsync(IBinaryContent fileConte
return uploadRequest;
}

/// <summary>
/// Verify upload file part asynchronously
/// </summary>
/// <param name="uploadRequest">UploadRequest</param>
/// <returns>Verification reponse</returns>
/// <inheritdoc />
public async Task<VerifyUploadResponse> VerifyUploadFileAsync(IUploadRequest uploadRequest)
{
try
Expand All @@ -239,6 +235,7 @@ public async Task<VerifyUploadResponse> VerifyUploadFileAsync(IUploadRequest upl
var verify = new VerifyUploadResponse();
CheckStatusCodeError(uploadRequest, response, "Error verifying file upload.", (HttpStatusCode)308);

// ReSharper disable once ConvertIfStatementToSwitchStatement
if (response.StatusCode == HttpStatusCode.OK)
{
verify.BytesWritten = uploadRequest.FileLength;
Expand All @@ -249,12 +246,11 @@ public async Task<VerifyUploadResponse> VerifyUploadFileAsync(IUploadRequest upl
verify.Status = UploadStatusEnum.InProgress;
if (!response.Headers.Contains("Range"))
return verify;
var startIndex = 0;
var endIndex = 0;
var match = RangeRegex.Match(response.Headers.GetValues("Range").First());
// ReSharper disable once InvertIf
if (match.Success
&& int.TryParse(match.Groups["start"].Value, out startIndex)
&& int.TryParse(match.Groups["end"].Value, out endIndex))
&& long.TryParse(match.Groups["start"].Value, out var startIndex)
&& long.TryParse(match.Groups["end"].Value, out var endIndex))
{
verify.BytesWritten = endIndex - startIndex;
if (verify.BytesWritten == uploadRequest.FileLength)
Expand Down

0 comments on commit f173851

Please sign in to comment.