Table of Contents

Class NoopObjectStorage

Namespace
Builvero.Infrastructure.Services
Assembly
Builvero.Infrastructure.dll

No-op implementation of IObjectStorage for testing or when S3 is disabled. Returns deterministic placeholder URLs without making any AWS calls.

public sealed class NoopObjectStorage : IObjectStorage
Inheritance
NoopObjectStorage
Implements
Inherited Members

Methods

DeleteAsync(string, CancellationToken)

Simulates a file deletion without performing any actual storage operation.

public Task<bool> DeleteAsync(string objectKey, CancellationToken cancellationToken = default)

Parameters

objectKey string

The object key of the file to delete.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task<bool>

Always returns true, simulating a successful deletion.

Remarks

This method always returns true without performing any actual deletion operations. Useful for testing scenarios where actual S3 access is not available.

GenerateGetUrlAsync(string, TimeSpan?, CancellationToken)

Generates a placeholder GET URL without making any AWS calls.

public Task<string> GenerateGetUrlAsync(string objectKey, TimeSpan? expiresIn = null, CancellationToken cancellationToken = default)

Parameters

objectKey string

The object key for the file to retrieve.

expiresIn TimeSpan?

Time until the URL expires (ignored in no-op implementation).

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task<string>

A placeholder GET URL.

Remarks

Returns a deterministic URL format: https://test.local/assets/{objectKey} No actual AWS S3 operations are performed.

GeneratePresignedGetUrlAsync(string, TimeSpan?, CancellationToken)

Generates a placeholder presigned GET URL that mimics AWS presigned URL format.

public Task<string> GeneratePresignedGetUrlAsync(string objectKey, TimeSpan? expiresIn = null, CancellationToken cancellationToken = default)

Parameters

objectKey string

The object key for the file to retrieve.

expiresIn TimeSpan?

Time until the URL expires. Defaults to 15 minutes if not specified.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task<string>

A placeholder presigned URL containing X-Amz- query parameters.

Remarks

Returns a URL that looks like a presigned URL (contains X-Amz- parameters) to allow tests to verify guardrail logic that checks for presigned URLs.

Format: https://test.local/assets/{objectKey}?X-Amz-Algorithm=...&X-Amz-Expires=...&X-Amz-Signature=test-signature...

No actual AWS S3 operations are performed.

GenerateUploadUrlAsync(string, string, TimeSpan?, CancellationToken)

Generates a placeholder upload URL without making any AWS calls.

public Task<(string UploadUrl, string ObjectKey)> GenerateUploadUrlAsync(string objectKey, string contentType, TimeSpan? expiresIn = null, CancellationToken cancellationToken = default)

Parameters

objectKey string

The object key for the file to upload.

contentType string

The MIME type of the file (ignored in no-op implementation).

expiresIn TimeSpan?

Time until the URL expires (ignored in no-op implementation).

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task<(string UploadUrl, string ObjectKey)>

A tuple containing a placeholder upload URL and the object key.

Remarks

Returns a deterministic URL format: https://test.local/assets/{objectKey}?upload=true No actual AWS S3 operations are performed.

UploadAsync(string, Stream, string, CancellationToken)

Simulates a file upload without performing any actual storage operation.

public Task<string> UploadAsync(string objectKey, Stream fileStream, string contentType, CancellationToken cancellationToken = default)

Parameters

objectKey string

The object key where the file would be stored.

fileStream Stream

The file stream to upload (ignored in no-op implementation).

contentType string

The MIME type of the file (ignored in no-op implementation).

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task<string>

The object key, simulating a successful upload.

Remarks

This method immediately returns the object key without reading from the stream or performing any storage operations. Useful for testing scenarios where actual S3 access is not available.