Table of Contents

Interface IObjectStorage

Namespace
Builvero.Application.Interfaces.Services
Assembly
Builvero.Application.dll

Abstraction for object storage operations (S3, local storage, etc.). Allows feature-flagging and test-safe implementations.

public interface IObjectStorage

Methods

DeleteAsync(string, CancellationToken)

Deletes a file from storage

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

Parameters

objectKey string

Storage object key

cancellationToken CancellationToken

Cancellation token

Returns

Task<bool>

True if the file was deleted successfully, false if it didn't exist

GenerateGetUrlAsync(string, TimeSpan?, CancellationToken)

Generates a pre-signed GET URL for retrieving a file from storage. This method may return a plain public URL if UsePublicUrls=true (for backward compatibility). For guaranteed presigned URLs, use GeneratePresignedGetUrlAsync instead.

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

Parameters

objectKey string

Storage object key

expiresIn TimeSpan?

Time until the URL expires

cancellationToken CancellationToken

Cancellation token

Returns

Task<string>

Pre-signed GET URL or public URL (depending on configuration)

GeneratePresignedGetUrlAsync(string, TimeSpan?, CancellationToken)

Generates a pre-signed GET URL for retrieving a file from storage. This method ALWAYS returns a presigned URL, regardless of UsePublicUrls setting. Use this method when you need a guaranteed presigned URL (e.g., for private buckets).

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

Parameters

objectKey string

Storage object key

expiresIn TimeSpan?

Time until the URL expires

cancellationToken CancellationToken

Cancellation token

Returns

Task<string>

Pre-signed GET URL with X-Amz- query parameters

GenerateUploadUrlAsync(string, string, TimeSpan?, CancellationToken)

Generates a pre-signed URL for uploading a file to storage

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

Parameters

objectKey string

Storage object key (e.g., "profile-photos/{userId}/{uuid}.jpg")

contentType string

MIME type of the file

expiresIn TimeSpan?

Time until the URL expires

cancellationToken CancellationToken

Cancellation token

Returns

Task<(string UploadUrl, string ObjectKey)>

Pre-signed upload URL and the object key

UploadAsync(string, Stream, string, CancellationToken)

Uploads a file directly to storage (server-side upload)

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

Parameters

objectKey string

Storage object key

fileStream Stream

The file stream to upload

contentType string

MIME type of the file

cancellationToken CancellationToken

Cancellation token

Returns

Task<string>

Object key where the file was stored