DataWeb
Search Results for

    Show / Hide Table of Contents

    Class FileStorageStore

    Azure Blob Storage implementation of IFileStorageStore. Files are stored as blobs inside Azure Blob Storage containers. The BlobServiceClient instance is shared across all calls (thread-safe singleton field).

    Inheritance
    object
    FileStorageStore
    Implements
    IFileStorageStore
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: DataWeb.Storage.AzureBlob
    Assembly: DataWeb.Storage.AzureBlob.dll
    Syntax
    public class FileStorageStore : IFileStorageStore

    Constructors

    FileStorageStore(IConfigurationService, ICacheService)

    Azure Blob Storage implementation of IFileStorageStore. Files are stored as blobs inside Azure Blob Storage containers. The BlobServiceClient instance is shared across all calls (thread-safe singleton field).

    Declaration
    public FileStorageStore(IConfigurationService configurationService, ICacheService cacheService)
    Parameters
    Type Name Description
    IConfigurationService configurationService
    ICacheService cacheService

    Properties

    Name

    Gets the unique name that identifies this storage provider.

    Declaration
    public string Name { get; }
    Property Value
    Type Description
    string

    Methods

    CloneFileAsync(string, string, string, string, CancellationToken)

    Copies a blob to a new location using the server-side Azure Blob copy API with an infinite lease to prevent modifications during the operation.

    Declaration
    public Task<StorageResult> CloneFileAsync(string sourceStorageFileName, string sourceStorageContainer, string targetStorageFileName, string targetStorageContainer, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string sourceStorageFileName

    The source blob name. Must not be null or empty.

    string sourceStorageContainer

    The source container name. Defaults to "files" when null or empty.

    string targetStorageFileName

    The target blob name. Must not be null or empty.

    string targetStorageContainer

    The target container name. Defaults to "files" when null or empty.

    CancellationToken cancellationToken

    A token to cancel the operation.

    Returns
    Type Description
    Task<StorageResult>

    A StorageResult indicating success or failure.

    DeleteFileAsync(string, string, CancellationToken)

    Deletes a blob from the specified container. Returns a failure result if the container or blob does not exist.

    Declaration
    public Task<StorageResult> DeleteFileAsync(string storageFileName, string storageContainer, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string storageFileName

    The blob name. Must not be null or empty.

    string storageContainer

    The container name. Defaults to "files" when null or empty.

    CancellationToken cancellationToken

    A token to cancel the operation.

    Returns
    Type Description
    Task<StorageResult>

    A StorageResult indicating success or failure.

    DownloadFileStreamAsync(string, string, string, CancellationToken)

    Opens a read stream for the specified blob, optionally scoped to a file domain. Throws if the container or blob does not exist.

    Declaration
    public Task<Stream> DownloadFileStreamAsync(string storageFileName, string storageContainer, string fileDomain = null, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string storageFileName

    The blob name. Must not be null or empty.

    string storageContainer

    The container name. Defaults to "files" when null or empty.

    string fileDomain

    An optional domain qualifier (currently unused in the Azure Blob implementation).

    CancellationToken cancellationToken

    A token to cancel the operation.

    Returns
    Type Description
    Task<Stream>

    A readable Stream backed by Azure Blob Storage.

    Exceptions
    Type Condition
    FileNotFoundException

    Thrown when the container or blob does not exist.

    FileExistsAsync(string, string, CancellationToken)

    Checks whether a blob with the given name exists in the specified container. Returns false if either the container or the blob does not exist.

    Declaration
    public Task<bool> FileExistsAsync(string storageFileName, string storageContainer, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string storageFileName

    The blob name. Must not be null or empty.

    string storageContainer

    The container name. Defaults to "files" when null or empty.

    CancellationToken cancellationToken

    A token to cancel the operation.

    Returns
    Type Description
    Task<bool>

    true if the blob exists; otherwise false.

    GetDeleteFromStorageContainerNameAsync(CancellationToken)

    Returns the name of the Azure Blob container used to store files moved during a delete-from-storage operation.

    Declaration
    public Task<string> GetDeleteFromStorageContainerNameAsync(CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    A token to cancel the operation (unused).

    Returns
    Type Description
    Task<string>

    The container name "deleted-from-storage".

    GetFilePropertiesAsync(string, string, CancellationToken)

    Retrieves the properties (size and content type) of a blob. Returns an empty StorageFileProperties if the container or blob does not exist.

    Declaration
    public Task<StorageFileProperties> GetFilePropertiesAsync(string storageFileName, string storageContainer, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string storageFileName

    The blob name. Must not be null or empty.

    string storageContainer

    The container name. Defaults to "files" when null or empty.

    CancellationToken cancellationToken

    A token to cancel the operation.

    Returns
    Type Description
    Task<StorageFileProperties>

    A StorageFileProperties instance with length and content type, or default values if not found.

    GetFileStreamAsync(string, string, CancellationToken)

    Opens a read stream for the specified blob. Delegates to DownloadFileStreamAsync(string, string, string, CancellationToken).

    Declaration
    public Task<Stream> GetFileStreamAsync(string storageFileName, string storageContainer, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string storageFileName

    The blob name. Must not be null or empty.

    string storageContainer

    The container name. Defaults to "files" when null or empty.

    CancellationToken cancellationToken

    A token to cancel the operation.

    Returns
    Type Description
    Task<Stream>

    A readable Stream for the blob content.

    Exceptions
    Type Condition
    FileNotFoundException

    Thrown when the container or blob does not exist.

    GetNewStorageFileName(string)

    Generates a new unique storage file name based on a Guid, preserving the .dataweb extension.

    Declaration
    public string GetNewStorageFileName(string fileName)
    Parameters
    Type Name Description
    string fileName

    The original file name. Must not be null or empty.

    Returns
    Type Description
    string

    A new unique file name with the .dataweb extension.

    GetStorageActualSizeAsync(CancellationToken)

    Calculates the total size in bytes of all blobs across all containers. Uses a cache with a 10-minute expiration per container and limits concurrency to 10 simultaneous container scans.

    Declaration
    public Task<long> GetStorageActualSizeAsync(CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    A token to cancel the operation.

    Returns
    Type Description
    Task<long>

    The total storage size in bytes.

    GetStorageMaxSizeAsync(CancellationToken)

    Returns the configured maximum storage size in bytes, as set via AzureBlob:StorageMaxSize.

    Declaration
    public Task<long> GetStorageMaxSizeAsync(CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    A token to cancel the operation (unused).

    Returns
    Type Description
    Task<long>

    The maximum allowed storage size in bytes.

    GetUploadContainerName()

    Returns the name of the Azure Blob container used for temporary uploads, as configured via AzureBlob:UploadContainerName. Defaults to "uploads".

    Declaration
    public string GetUploadContainerName()
    Returns
    Type Description
    string

    The upload container name.

    MoveFileAsync(string, string, string, string, CancellationToken)

    Moves a blob by cloning it to the target location and then deleting the source. If either step fails, the corresponding failure result is returned.

    Declaration
    public Task<StorageResult> MoveFileAsync(string sourceStorageFileName, string sourceStorageContainer, string targetStorageFileName, string targetStorageContainer, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string sourceStorageFileName

    The source blob name. Must not be null or empty.

    string sourceStorageContainer

    The source container name. Defaults to "files" when null or empty.

    string targetStorageFileName

    The target blob name. Must not be null or empty.

    string targetStorageContainer

    The target container name. Defaults to "files" when null or empty.

    CancellationToken cancellationToken

    A token to cancel the operation.

    Returns
    Type Description
    Task<StorageResult>

    A StorageResult indicating success or failure.

    UploadChunkStreamAsync(Stream, int, int, int, long, string, string, CancellationToken)

    Uploads a single chunk of a multipart file using Azure Block Blob staging. When the last chunk is received (chunkNumber == chunkCount), all staged blocks are committed in order.

    Declaration
    public Task<StorageResult> UploadChunkStreamAsync(Stream stream, int chunkNumber, int chunkSize, int chunkCount, long storageFileSize, string storageFileName, string storageContainer, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    Stream stream

    The stream containing the chunk data.

    int chunkNumber

    The 1-based index of the current chunk.

    int chunkSize

    The size in bytes of each chunk.

    int chunkCount

    The total number of chunks.

    long storageFileSize

    The total size in bytes of the complete file.

    string storageFileName

    The target blob name. Must not be null or empty.

    string storageContainer

    The container name. Defaults to "files" when null or empty.

    CancellationToken cancellationToken

    A token to cancel the operation.

    Returns
    Type Description
    Task<StorageResult>

    A StorageResult indicating success or failure.

    UploadFileStreamAsync(Stream, string, string, CancellationToken)

    Uploads a stream as a blob, creating the container if it does not exist. Overwrites any existing blob with the same name.

    Declaration
    public Task<StorageResult> UploadFileStreamAsync(Stream stream, string storageFileName, string storageContainer, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    Stream stream

    The stream to upload. The position is reset to 0 before uploading.

    string storageFileName

    The target blob name. Must not be null or empty.

    string storageContainer

    The container name. Defaults to "files" when null or empty.

    CancellationToken cancellationToken

    A token to cancel the operation.

    Returns
    Type Description
    Task<StorageResult>

    A StorageResult indicating success or failure.

    Implements

    IFileStorageStore
    In this article
    Back to top Generated by DocFX