Skip to content

Conversation

dundich
Copy link
Contributor

@dundich dundich commented Apr 29, 2025

No description provided.

@dundich
Copy link
Contributor Author

dundich commented Apr 29, 2025

#9 для тикета переименовал клиента в S3BucketClient

  1. Завел интерфейсы
public interface IS3BucketClient: IBucketOperations, IFileOperations
{
	string Bucket { get; }
	Uri Endpoint { get; }
}

public interface IBucketOperations
{
	Task<bool> CreateBucket(CancellationToken ct);
	Task<bool> DeleteBucket(CancellationToken ct);
	Task<bool> IsBucketExists(CancellationToken ct);
}

public interface IFileOperations
{
	string BuildFileUrl(string fileName, TimeSpan expiration);
	Task DeleteFile(string fileName, CancellationToken ct);
	Task<S3File> GetFile(string fileName, CancellationToken ct);
	Task<Stream> GetFileStream(string fileName, CancellationToken ct);
	Task<string?> GetFileUrl(string fileName, TimeSpan expiration, CancellationToken ct);
	Task<bool> IsFileExists(string fileName, CancellationToken ct);
	IAsyncEnumerable<string> List(string? prefix, CancellationToken ct);
	Task<bool> UploadFile(string fileName, string contentType, byte[] data, CancellationToken ct);
	Task<S3Upload> UploadFile(string fileName, string contentType, CancellationToken ct);
	Task<bool> UploadFile(string fileName, string contentType, Stream data, CancellationToken ct);
}
  1. Тесты - ok

  2. Старого заопсалетил (оставил для перехода)

[Obsolete("Use S3BucketClient instead.")]
public sealed class S3Client(S3Settings settings, HttpClient? client = null, IArrayPool? arrayProvider = null)
	: S3BucketClient(client ?? new HttpClient(), settings.MapToBucketSettings(), arrayProvider)
{
}

@dundich
Copy link
Contributor Author

dundich commented May 5, 2025

  1. Перенес в UrlUtils методы для работы с uri (тестебилити апнул)
  2. Добавил тест и оптимизировал UrlUtils.AppendCanonicalQueryParameters(ref builder, "?key=value");
  3. Запрятал взад IArrayPool - показалось много инвазий, но оставил дешевый компромисс задать стратегию на старте (пока показалось рано его еще выносить в зависимости - сыроват и не везде был пропихан)
  4. Добавил TimeProvider

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant