Table of Contents

Interface IStorageProvider

Namespace
CloudStorageORM.Interfaces.StorageProviders
Assembly
CloudStorageORM.dll
public interface IStorageProvider

Properties

CloudProvider

Gets the cloud provider represented by this storage implementation.

CloudProvider CloudProvider { get; }

Property Value

CloudProvider

Methods

CreateContainerIfNotExistsAsync()

Creates the container or bucket if it does not already exist.

Task CreateContainerIfNotExistsAsync()

Returns

Task

Examples

await storageProvider.CreateContainerIfNotExistsAsync();

DeleteAsync(string)

Deletes an object from storage without an ETag precondition.

Task DeleteAsync(string path)

Parameters

path string

Object path inside the container.

Returns

Task

Examples

await storageProvider.DeleteAsync("users/42.json");

DeleteAsync(string, string?)

Deletes an object from storage using an optional ETag precondition.

Task DeleteAsync(string path, string? ifMatchETag)

Parameters

path string

Object path inside the container.

ifMatchETag string

Expected ETag value used for optimistic concurrency.

Returns

Task

Examples

await storageProvider.DeleteAsync("users/42.json", currentEtag);

DeleteContainerAsync()

Deletes the underlying container or bucket when it exists.

Task DeleteContainerAsync()

Returns

Task

Examples

await storageProvider.DeleteContainerAsync();

ListAsync(string)

Lists object paths under a folder-like prefix.

Task<List<string>> ListAsync(string folderPath)

Parameters

folderPath string

Folder or prefix to search.

Returns

Task<List<string>>

List of matching object paths.

Examples

var keys = await storageProvider.ListAsync("users/");

ListPageAsync(string, int, string?, CancellationToken)

Lists object paths under a folder-like prefix as a single page with continuation support.

Task<StorageListPage> ListPageAsync(string folderPath, int pageSize, string? continuationToken, CancellationToken cancellationToken = default)

Parameters

folderPath string

Folder or prefix to search.

pageSize int

Maximum number of keys to return for this page.

continuationToken string

Continuation token returned by a previous call, if any.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<StorageListPage>

A page of keys and continuation information.

Examples

var page = await storageProvider.ListPageAsync("users/", 100, null);

ReadAsync<T>(string)

Reads and deserializes an entity payload from object storage.

Task<T> ReadAsync<T>(string path)

Parameters

path string

Object path inside the container.

Returns

Task<T>

The deserialized entity payload.

Type Parameters

T

Entity payload type to deserialize.

Examples

var user = await storageProvider.ReadAsync<User>("users/42.json");

ReadWithMetadataAsync<T>(string)

Reads an entity payload and its metadata from object storage.

Task<StorageObject<T>> ReadWithMetadataAsync<T>(string path)

Parameters

path string

Object path inside the container.

Returns

Task<StorageObject<T>>

A wrapper containing the entity value, ETag, and existence status.

Type Parameters

T

Entity payload type to deserialize.

Examples

var result = await storageProvider.ReadWithMetadataAsync<User>("users/42.json");
if (result.Exists) { Console.WriteLine(result.ETag); }

SanitizeBlobName(string)

Sanitizes a raw blob name so it can be safely used by the provider.

string SanitizeBlobName(string rawName)

Parameters

rawName string

Original blob or folder name.

Returns

string

Provider-safe normalized name.

Examples

var safeName = storageProvider.SanitizeBlobName("My Entity");

SaveAsync<T>(string, T)

Persists an entity payload at the specified path without an ETag precondition.

Task SaveAsync<T>(string path, T entity)

Parameters

path string

Object path inside the container.

entity T

Entity payload to store.

Returns

Task

Type Parameters

T

Entity payload type to serialize.

Examples

await storageProvider.SaveAsync("users/42.json", user);

SaveAsync<T>(string, T, string?)

Persists an entity payload using an optional ETag precondition and returns the resulting ETag.

Task<string?> SaveAsync<T>(string path, T entity, string? ifMatchETag)

Parameters

path string

Object path inside the container.

entity T

Entity payload to store.

ifMatchETag string

Expected ETag value used for optimistic concurrency.

Returns

Task<string>

The new ETag when available; otherwise null.

Type Parameters

T

Entity payload type to serialize.

Examples

var newEtag = await storageProvider.SaveAsync("users/42.json", user, currentEtag);