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
objectKeystringThe object key of the file to delete.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
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
objectKeystringThe object key for the file to retrieve.
expiresInTimeSpan?Time until the URL expires (ignored in no-op implementation).
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
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
objectKeystringThe object key for the file to retrieve.
expiresInTimeSpan?Time until the URL expires. Defaults to 15 minutes if not specified.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
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
objectKeystringThe object key for the file to upload.
contentTypestringThe MIME type of the file (ignored in no-op implementation).
expiresInTimeSpan?Time until the URL expires (ignored in no-op implementation).
cancellationTokenCancellationTokenCancellation 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
objectKeystringThe object key where the file would be stored.
fileStreamStreamThe file stream to upload (ignored in no-op implementation).
contentTypestringThe MIME type of the file (ignored in no-op implementation).
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
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.