Skip to content

Commit

Permalink
CancellationToken support added
Browse files Browse the repository at this point in the history
  • Loading branch information
hkutluay committed Dec 6, 2020
1 parent cf6718f commit 65ee26d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 5 additions & 4 deletions ZipContent.Azure/AzurePartialFileReader.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Azure;
using Azure.Storage.Blobs;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using ZipContent.Core;

Expand All @@ -15,16 +16,16 @@ public AzurePartialFileReader(BlobClient blobClient)
_blobClient = blobClient;
}

public async Task<long> ContentLength()
public async Task<long> ContentLength(CancellationToken cancellationToken = default)
{
var props = await _blobClient.GetPropertiesAsync();
var props = await _blobClient.GetPropertiesAsync(null, cancellationToken);
return props.Value.ContentLength;
}

public async Task<byte[]> GetBytes(ByteRange range)
public async Task<byte[]> GetBytes(ByteRange range, CancellationToken cancellationToken = default)
{

var data = await _blobClient.DownloadAsync(new HttpRange(range.Start, range.End - range.Start));
var data = await _blobClient.DownloadAsync(new HttpRange(range.Start, range.End - range.Start), null, false, cancellationToken);
return StreamToArray(data.Value.Content);

}
Expand Down
5 changes: 4 additions & 1 deletion ZipContent.Azure/ZipContent.Azure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ Lists zip file content on Azure Blob without downloading whole document. Support
<RepositoryUrl>https://github.com/hkutluay/ZipContent.Azure</RepositoryUrl>
<PackageTags>zip list content azure</PackageTags>
<PackageIcon>azure_logo.png</PackageIcon>
<Version>1.1.0</Version>
<AssemblyVersion>1.1.0.0</AssemblyVersion>
<FileVersion>1.1.0.0</FileVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Storage.Blobs" Version="12.4.2" />
<PackageReference Include="ZipContent.Core" Version="1.0.0" />
<PackageReference Include="ZipContent.Core" Version="1.1.1" />
</ItemGroup>
<ItemGroup>
<None Include="azure_logo.png">
Expand Down

0 comments on commit 65ee26d

Please sign in to comment.