DataWeb
Search Results for

    Show / Hide Table of Contents

    Class FileStorageStore

    File storage implementation using the local file system. Provides operations to upload, download, move, clone, and delete files within a sandboxed storage path to prevent unauthorized access.

    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.FileSystem
    Assembly: DataWeb.Storage.FileSystem.dll
    Syntax
    public class FileStorageStore : IFileStorageStore

    Constructors

    FileStorageStore(IConfigurationService, ISharedKeyService, IEnvironmentService, IHttpClientFactory)

    File storage implementation using the local file system. Provides operations to upload, download, move, clone, and delete files within a sandboxed storage path to prevent unauthorized access.

    Declaration
    public FileStorageStore(IConfigurationService configurationService, ISharedKeyService sharedKeyService, IEnvironmentService environmentService, IHttpClientFactory httpClientFactory)
    Parameters
    Type Name Description
    IConfigurationService configurationService
    ISharedKeyService sharedKeyService
    IEnvironmentService environmentService
    IHttpClientFactory httpClientFactory

    Properties

    Name

    Gets the name of the file storage store.

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

    Methods

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

    Copies a file from one storage location to another using an async stream copy. The target file is created or overwritten.

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

    The source file name.

    string sourceStorageContainer

    The source container. Defaults to Files if null or empty.

    string targetStorageFileName

    The target file name.

    string targetStorageContainer

    The target container. Defaults to Files if null or empty.

    CancellationToken cancellationToken

    Cancellation token.

    Returns
    Type Description
    Task<StorageResult>

    A StorageResult indicating success or failure.

    DeleteFileAsync(string, string, CancellationToken)

    Deletes a file from the specified storage container. Returns a failure result if the file does not exist.

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

    The storage file name.

    string storageContainer

    The storage container. Defaults to Files if null or empty.

    CancellationToken cancellationToken

    Cancellation token.

    Returns
    Type Description
    Task<StorageResult>

    A StorageResult indicating success or failure.

    DownloadFileStreamAsync(string, string, string, CancellationToken)

    Downloads a file stream from a remote domain via an authenticated HTTP request.

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

    The storage file name to download.

    string storageContainer

    The storage container. Defaults to Files if null or empty.

    string fileDomain

    The base URL of the remote storage endpoint.

    CancellationToken cancellationToken

    Cancellation token.

    Returns
    Type Description
    Task<Stream>

    A Stream with the remote file content.

    FileExistsAsync(string, string, CancellationToken)

    Determines whether a file exists in the specified storage container. Returns false if the path fails validation.

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

    The storage file name.

    string storageContainer

    The storage container. Defaults to Files if null or empty.

    CancellationToken cancellationToken

    Cancellation token.

    Returns
    Type Description
    Task<bool>

    true if the file 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 type) of a file in the specified storage container. Returns a StorageFileProperties with Length = 0 if the file does not exist or if the path fails validation.

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

    The storage file name.

    string storageContainer

    The storage container. Defaults to Files if null or empty.

    CancellationToken cancellationToken

    Cancellation token.

    Returns
    Type Description
    Task<StorageFileProperties>

    A StorageFileProperties with the file metadata.

    GetFileStreamAsync(string, string, CancellationToken)

    Opens and returns a read-only stream for the specified file.

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

    The storage file name.

    string storageContainer

    The storage container. Defaults to Files if null or empty.

    CancellationToken cancellationToken

    Cancellation token.

    Returns
    Type Description
    Task<Stream>

    A readable Stream for the file.

    Exceptions
    Type Condition
    ArgumentException

    Thrown if the path fails security validation.

    GetNewStorageFileName(string)

    Returns a new unique storage file name, ignoring the original file name. The returned name is a GUID with the .dataweb extension.

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

    The original file name (used only for validation).

    Returns
    Type Description
    string

    A unique storage file name.

    GetStorageActualSizeAsync(CancellationToken)

    Calculates the total size in bytes of all files currently stored under the storage root path.

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

    Cancellation token.

    Returns
    Type Description
    Task<long>

    The total storage size in bytes.

    GetStorageMaxSizeAsync(CancellationToken)

    Returns the maximum allowed storage size in bytes as configured in application settings.

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

    Cancellation token.

    Returns
    Type Description
    Task<long>

    The maximum storage size in bytes.

    GetUploadContainerName()

    Returns the default upload container name.

    Declaration
    public string GetUploadContainerName()
    Returns
    Type Description
    string

    The upload container name.

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

    Moves a file from one storage location to another, overwriting any existing target file.

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

    The source file name.

    string sourceStorageContainer

    The source container. Defaults to Files if null or empty.

    string targetStorageFileName

    The target file name.

    string targetStorageContainer

    The target container. Defaults to Files if null or empty.

    CancellationToken cancellationToken

    Cancellation token.

    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 multi-part file upload. Chunks must be uploaded in sequential order; if the expected byte offset does not match the current file size, the operation returns a Missing chunk error.

    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 expected file size in bytes.

    string storageFileName

    The storage file name.

    string storageContainer

    The storage container. Defaults to Files if null or empty.

    CancellationToken cancellationToken

    Cancellation token.

    Returns
    Type Description
    Task<StorageResult>

    A StorageResult indicating success or failure.

    UploadFileStreamAsync(Stream, string, string, CancellationToken)

    Uploads an entire file stream to the specified storage container. If a file with the same name already exists, it is overwritten. The stream is read from the beginning regardless of its current position.

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

    The stream containing the file data.

    string storageFileName

    The storage file name.

    string storageContainer

    The storage container. Defaults to Files if null or empty.

    CancellationToken cancellationToken

    Cancellation token.

    Returns
    Type Description
    Task<StorageResult>

    A StorageResult indicating success or failure.

    Implements

    IFileStorageStore
    In this article
    Back to top Generated by DocFX