Feature: Amazon S3 Provider (ManagedCode.Storage.Aws)
Purpose
Implement IStorage on top of Amazon S3, including streaming and container (bucket) management semantics where applicable.
Main Flows
flowchart LR
App --> S3[AWSStorage : IAWSStorage]
S3 --> SDK[Amazon.S3 IAmazonS3]
SDK --> S3Cloud[(Amazon S3)]
Components
Storages/ManagedCode.Storage.Aws/AWSStorage.csStorages/ManagedCode.Storage.Aws/AWSStorageProvider.csStorages/ManagedCode.Storage.Aws/BlobStream.cs- DI:
- Options:
DI Wiring
dotnet add package ManagedCode.Storage.Aws
using Amazon.S3;
using ManagedCode.Storage.Aws.Extensions;
builder.Services.AddAWSStorageAsDefault(options =>
{
options.Bucket = "my-bucket";
options.PublicKey = configuration["Aws:AccessKeyId"];
options.SecretKey = configuration["Aws:SecretAccessKey"];
options.OriginalOptions = new AmazonS3Config { RegionEndpoint = Amazon.RegionEndpoint.USEast1 };
});
Current Behavior
- Downloads read the body and metadata from one S3 response. Metadata returns the object key relative to its bucket. Listings follow the service’s continuation tokens.
- The multipart write stream buffers parts in temporary files and keeps at most two part uploads in flight. If a write or upload fails, it closes the buffers and aborts the pending multipart upload.
-
Multipart writes accept byte arrays and spans directly.
SetLengthis a nonnegative sizing hint for an open writer. - Supports multiple auth modes (access keys / role / instance profile) via
AWSStorageOptions. - Can create the bucket when
CreateContainerIfNotExists = true.
Tests
Tests/ManagedCode.Storage.Tests/Storages/AWS/AWSUploadTests.csTests/ManagedCode.Storage.Tests/Storages/AWS/AWSDownloadTests.csTests/ManagedCode.Storage.Tests/Storages/AWS/AWSBlobTests.csTests/ManagedCode.Storage.Tests/Storages/AWS/AWSContainerTests.csTests/ManagedCode.Storage.Tests/Storages/AWS/AwsConfigTests.cs