Table of Contents

Class AwsS3StorageProvider

Namespace
CloudStorageORM.Providers.Aws.StorageProviders
Assembly
CloudStorageORM.dll

Amazon S3 implementation of IStorageProvider.

public class AwsS3StorageProvider : IStorageProvider
Inheritance
AwsS3StorageProvider
Implements
Inherited Members

Constructors

AwsS3StorageProvider(CloudStorageOptions)

Creates a new Amazon S3 storage provider from CloudStorageORM options.

public AwsS3StorageProvider(CloudStorageOptions options)

Parameters

options CloudStorageOptions

Validated CloudStorageORM options containing AWS credentials, region, and bucket name.

Examples

var provider = new AwsS3StorageProvider(options);

Properties

CloudProvider

Gets the cloud provider represented by this storage implementation.

public CloudProvider CloudProvider { get; }

Property Value

CloudProvider

Methods

CreateContainerIfNotExistsAsync()

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

public Task CreateContainerIfNotExistsAsync()

Returns

Task

Examples

await storageProvider.CreateContainerIfNotExistsAsync();

DeleteAsync(string)

Deletes an object from storage without an ETag precondition.

public 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.

public 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.

public Task DeleteContainerAsync()

Returns

Task

Examples

await storageProvider.DeleteContainerAsync();

ListAsync(string)

Lists object paths under a folder-like prefix.

public 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.

public 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.

public 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.

public 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.

public 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.

public 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.

public 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);