Class InMemoryAzureBlobProvider
A simple in-memory mock implementation of functionality to interact with Azure blob storage.
Inherited Members
Namespace: CrashCABN.DataAccess
Assembly: CrashCABN.DataAccess.Blobs.dll
Syntax
public sealed record InMemoryAzureBlobProvider : IAzureBlobProvider, IEquatable<InMemoryAzureBlobProvider>
Constructors
View SourceInMemoryAzureBlobProvider(Func<Uri, Task<Stream>>?)
A simple in-memory mock implementation of functionality to interact with Azure blob storage.
Declaration
public InMemoryAzureBlobProvider(Func<Uri, Task<Stream>>? Download = null)
Parameters
Type | Name | Description |
---|---|---|
Func<Uri, Task<Stream>> | Download |
Properties
View SourceDownload
Declaration
public Func<Uri, Task<Stream>>? Download { get; init; }
Property Value
Type | Description |
---|---|
Func<Uri, Task<Stream>> |
Methods
View SourceBlobExistsAsync(Uri)
Checks if the blob exists for downloading.
Declaration
public Task<bool> BlobExistsAsync(Uri blobUri)
Parameters
Type | Name | Description |
---|---|---|
Uri | blobUri | The absolute blob URI. |
Returns
Type | Description |
---|---|
Task<bool> | True if it exists. |
CopyBlobFromUriAsync(Uri, Uri)
Uploads a copy of the source blob to the given blob URI.
Declaration
public Task CopyBlobFromUriAsync(Uri destinationUri, Uri sourceUri)
Parameters
Type | Name | Description |
---|---|---|
Uri | destinationUri | The blob URI to upload to. |
Uri | sourceUri | The blob URI to copy from. |
Returns
Type | Description |
---|---|
Task | A task representing the asynchronous operation. |
CreateContainerIfNotExistsAsync(Uri)
Creates the container for the given blob, if it doesn't already exist.
Declaration
public Task CreateContainerIfNotExistsAsync(Uri blobUri)
Parameters
Type | Name | Description |
---|---|---|
Uri | blobUri | The full URL to the Azure storage container and folder to search in. |
Returns
Type | Description |
---|---|
Task | A task that completes once the container is created. |
DeleteBlobIfExistsAsync(Uri)
Deletes the blob if it exists.
Declaration
public Task DeleteBlobIfExistsAsync(Uri blobUri)
Parameters
Type | Name | Description |
---|---|---|
Uri | blobUri | The absolute blob URI. |
Returns
Type | Description |
---|---|
Task | A task representing the asynchronous operation. |
GenerateReadOnlySASUriAsync(Uri, DateTimeOffset)
Generates a read-only URI with a SAS token to access the given blob.
Declaration
public Task<Uri> GenerateReadOnlySASUriAsync(Uri sourceUri, DateTimeOffset expiresOn)
Parameters
Type | Name | Description |
---|---|---|
Uri | sourceUri | The blob URI to use. |
DateTimeOffset | expiresOn | When the SAS token should expire. |
Returns
Type | Description |
---|---|
Task<Uri> | The SAS token URI. |
GetBlobPropertiesAsync(Uri)
Gets the blob properties if it exists.
Declaration
public Task<(long Size, byte[] Hash, DateTimeOffset LastModified)?> GetBlobPropertiesAsync(Uri blobUri)
Parameters
Type | Name | Description |
---|---|---|
Uri | blobUri | The absolute blob URI. |
Returns
Type | Description |
---|---|
Task<(long Size, byte[] Hash, DateTimeOffset LastModified)?> | The blob size, content hash, and last modified timestamp, or null if it doesn't exist. |
GetBlobStreamAndHashAsync(Uri)
Retrieves the blob stream for downloading and a content hash.
Declaration
public Task<(Stream Stream, byte[] Hash)> GetBlobStreamAndHashAsync(Uri blobUri)
Parameters
Type | Name | Description |
---|---|---|
Uri | blobUri | The absolute blob URI. |
Returns
Type | Description |
---|---|
Task<(Stream Stream, byte[] Hash)> | The stream for downloading and a content hash. |
GetBlobStreamAsync(Uri)
Retrieves the blob stream for downloading.
Declaration
public Task<Stream> GetBlobStreamAsync(Uri blobUri)
Parameters
Type | Name | Description |
---|---|---|
Uri | blobUri | The absolute blob URI. |
Returns
Type | Description |
---|---|
Task<Stream> | The stream for downloading. |
ListBlobsInPathAsync(Uri)
Lists the blobs in the given container path.
Declaration
public IAsyncEnumerable<string> ListBlobsInPathAsync(Uri blobUri)
Parameters
Type | Name | Description |
---|---|---|
Uri | blobUri | The full URL to the Azure storage container and folder to search in. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<string> | An enumeration containing the full path of each blob. |
WriteBlobStream(Uri, Stream)
Declaration
public void WriteBlobStream(Uri blobUri, Stream content)
Parameters
Type | Name | Description |
---|---|---|
Uri | blobUri | |
Stream | content |
WriteBlobStreamAsync(Uri, Stream)
Uploads the stream to the given blob URI.
Declaration
public Task WriteBlobStreamAsync(Uri blobUri, Stream content)
Parameters
Type | Name | Description |
---|---|---|
Uri | blobUri | The absolute blob URI. |
Stream | content | The stream for uploading. |
Returns
Type | Description |
---|---|
Task | A task representing the asynchronous operation. |
WriteBlobString(Uri, string)
Declaration
public void WriteBlobString(Uri blobUri, string content)
Parameters
Type | Name | Description |
---|---|---|
Uri | blobUri | |
string | content |