logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class FileStore

    IBlobStore implementation over a file system + writer.
    Exposes async members required by the hierarchy (IPersistenceStore, IKeyedStore, IReadOnlyBlobStore, IBlobStore).
    Maintains synchronous helpers for internal use where appropriate.

    Inheritance
    object
    FileStore
    Implements
    IBlobStore
    IReadOnlyBlobStore
    IKeyedStore
    IPersistenceStore
    IAppendableBlobStore
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.FilePersistence.Application.Services
    Assembly: Serenity.Global.Application.dll
    Syntax
    public class FileStore : IBlobStore, IReadOnlyBlobStore, IKeyedStore, IPersistenceStore, IAppendableBlobStore

    Constructors

    FileStore(IFileSystemService, IFileWriterService, string)

    Initializes a new instance of the FileStore class.

    Declaration
    public FileStore(IFileSystemService fileSystem, IFileWriterService fileWriter, string nameSpace = "file")
    Parameters
    Type Name Description
    IFileSystemService fileSystem

    File system service instance.

    IFileWriterService fileWriter

    File writer instance.

    string nameSpace

    Logical namespace for diagnostics/telemetry. Defaults to DEFAULT_NAMESPACE.

    Fields

    DEFAULT_NAMESPACE

    Default logical namespace identifying this store as file-based persistence.

    Declaration
    public const string DEFAULT_NAMESPACE = "file"
    Field Value
    Type Description
    string

    Properties

    Namespace

    Logical namespace for diagnostics/telemetry. Defaults to "file".

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

    Methods

    AppendAsync(string, Stream, bool, CancellationToken)

    Appends the provided data to the blob with the specified key, creating it if it doesn't exist.

    Declaration
    public Task AppendAsync(string key, Stream data, bool createIfMissing, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    string key

    The key of the blob to append to.

    Stream data

    The data to append.

    bool createIfMissing

    Whether to create the blob if it doesn't exist.

    CancellationToken cancellationToken

    Cancellation token for the async operation.

    Returns
    Type Description
    Task

    Task representing the asynchronous operation.

    AppendAsync(string, ReadOnlyMemory<byte>, bool, CancellationToken)

    Appends the provided data to the blob with the specified key, creating it if it doesn't exist.

    Declaration
    public Task AppendAsync(string key, ReadOnlyMemory<byte> data, bool createIfMissing, CancellationToken cancellatinToken)
    Parameters
    Type Name Description
    string key

    The key of the blob to append to.

    ReadOnlyMemory<byte> data

    The data to append.

    bool createIfMissing

    Whether to create the blob if it doesn't exist.

    CancellationToken cancellatinToken

    Cancellation token for the async operation.

    Returns
    Type Description
    Task

    Task representing the asynchronous operation.

    Delete(string)

    Deletes the blob with the specified key from the store, if it exists.

    Declaration
    public void Delete(string key)
    Parameters
    Type Name Description
    string key

    DeleteAsync(string, CancellationToken)

    Asynchronously deletes the blob with the specified key from the store, if it exists.

    Declaration
    public Task DeleteAsync(string key, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    string key
    CancellationToken cancellationToken
    Returns
    Type Description
    Task

    Exists(string)

    Checks if a blob with the specified key exists in the store.

    Declaration
    public bool Exists(string key)
    Parameters
    Type Name Description
    string key
    Returns
    Type Description
    bool

    True if the blob exists; otherwise, false.

    ExistsAsync(string, CancellationToken)

    Asynchronously checks if a blob with the specified key exists in the store.

    Declaration
    public Task<bool> ExistsAsync(string key, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    string key
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<bool>

    True if the blob exists; otherwise, false.

    GetLengthAsync(string, CancellationToken)

    Gets the length of the blob with the specified key, or null if it doesn't exist or can't be determined.

    Declaration
    public Task<long?> GetLengthAsync(string key, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    string key
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<long?>

    The length of the blob in bytes, or null if not available.

    HealthCheckAsync(CancellationToken)

    Performs a health check on the file store.

    Declaration
    public Task<bool> HealthCheckAsync(CancellationToken cancellationToken)
    Parameters
    Type Name Description
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<bool>

    True if the store is healthy; otherwise, false.

    OpenReadAsync(string, CancellationToken)

    Opens a read stream for the blob with the specified key.

    Declaration
    public Task<Stream> OpenReadAsync(string key, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    string key
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<Stream>

    A stream for reading the blob.

    ReadBytes(string)

    Reads the bytes from the blob with the specified key.

    Declaration
    public byte[] ReadBytes(string key)
    Parameters
    Type Name Description
    string key
    Returns
    Type Description
    byte[]

    The bytes read from the blob.

    ReadBytesAsync(string, CancellationToken)

    Asynchronously reads the bytes from the blob with the specified key.

    Declaration
    public Task<byte[]> ReadBytesAsync(string key, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string key
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<byte[]>

    The bytes read from the blob.

    WriteAsync(string, Stream, CancellationToken)

    Writes the provided content to the blob with the specified key, overwriting if it already exists.

    Declaration
    public Task WriteAsync(string key, Stream content, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    string key
    Stream content
    CancellationToken cancellationToken
    Returns
    Type Description
    Task

    Task representing the asynchronous operation.

    WriteAsync(string, ReadOnlyMemory<byte>, CancellationToken)

    Writes the provided content to the blob with the specified key, overwriting if it already exists.

    Declaration
    public Task WriteAsync(string key, ReadOnlyMemory<byte> content, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    string key
    ReadOnlyMemory<byte> content
    CancellationToken cancellationToken
    Returns
    Type Description
    Task

    Task representing the asynchronous operation.

    WriteBytes(string, byte[])

    Writes the provided bytes to the blob with the specified key, overwriting if it already exists.

    Declaration
    public void WriteBytes(string key, byte[] bytes)
    Parameters
    Type Name Description
    string key
    byte[] bytes

    WriteBytesAsync(string, byte[], CancellationToken)

    Asynchronously writes the provided bytes to the blob with the specified key, overwriting if it already exists.

    Declaration
    public Task WriteBytesAsync(string key, byte[] bytes, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    string key
    byte[] bytes
    CancellationToken cancellationToken
    Returns
    Type Description
    Task

    Task representing the asynchronous operation.

    Implements

    IBlobStore
    IReadOnlyBlobStore
    IKeyedStore
    IPersistenceStore
    IAppendableBlobStore
    In this article
    © 2026 Serenity. All Rights Reserved