Cloud.File.Storage.Manager.AmazonS3
3.0.0
dotnet add package Cloud.File.Storage.Manager.AmazonS3 --version 3.0.0
NuGet\Install-Package Cloud.File.Storage.Manager.AmazonS3 -Version 3.0.0
<PackageReference Include="Cloud.File.Storage.Manager.AmazonS3" Version="3.0.0" />
<PackageVersion Include="Cloud.File.Storage.Manager.AmazonS3" Version="3.0.0" />
<PackageReference Include="Cloud.File.Storage.Manager.AmazonS3" />
paket add Cloud.File.Storage.Manager.AmazonS3 --version 3.0.0
#r "nuget: Cloud.File.Storage.Manager.AmazonS3, 3.0.0"
#:package Cloud.File.Storage.Manager.AmazonS3@3.0.0
#addin nuget:?package=Cloud.File.Storage.Manager.AmazonS3&version=3.0.0
#tool nuget:?package=Cloud.File.Storage.Manager.AmazonS3&version=3.0.0
Cloud File Storage Manager
Provides complete implementation to handle easily cloud file storage operations like get informations about files, reading, downloadURL generation, file update, file move and delete. Primarily for Amazon S3 right now.
Built on the AWS SDK for .NET v4 (AWSSDK.S3 4.x). Checksums are computed and validated only where S3 requires them, so S3 compatible servers keep working. The SDK's own AWS_ENDPOINT_URL_S3 environment variable points the client at another endpoint (for example LocalStack); presigned download URLs then use that endpoint's scheme.
Configuration
Let's add a section to the appsettings.json
"AmazonS3torageSettings": {
"IsAnonymus": false,
"AccessKey": "",
"SecretKey": "",
"BucketName": "",
"BucketRegion": ""
}
In the application, configure this settings part
services.AddSingleton<ICloudFileStorageManager, AmazonS3FileStorageManager>(services => new AmazonS3FileStorageManager(new AmazonS3FileStorageManagerOptions()
{
IsAnonymus = config.GetSection("AmazonS3torageSettings").GetValue<bool>("IsAnonymus"),
AccessKey = config.GetSection("AmazonS3torageSettings").GetValue<string>("AccessKey"),
SecretKey = config.GetSection("AmazonS3torageSettings").GetValue<string>("SecretKey"),
BucketName = config.GetSection("AmazonS3torageSettings").GetValue<string>("BucketName"),
BucketRegion = config.GetSection("AmazonS3torageSettings").GetValue<string>("BucketRegion")
}));
Behaviour
- Directory listings return one level: the files directly in the folder plus its sub-folders (from the S3 common prefixes). Folder marker keys ending with
/are not listed as files. - File info is resolved with a single
ListObjectsV2request for the exact key, so onlys3:ListBucketis needed;s3:GetObjectands3:ListBucketVersionsare not required for it. - Deleting a folder removes every key under its prefix in pages of up to 1000 keys. If S3 reports any failed key, an
IOExceptionis thrown naming the first failure. - Delete returns
truewhen something was deleted andfalsewhen nothing existed under the path. - Moving copies the object with a single
CopyObjectrequest and then deletes the original; S3 limits this to objects of at most 5 GB. - Use
ReadFileVersionAsync(versionId, pathSegments)to read a specific object version with root-relative path segments; a null or empty version id reads the current version. The olderReadFileAsync(versionId, absolutePathSegments)overload is obsolete and only accepts paths under the configured root. On a variable typed asAmazonS3FileStorageManager, a call likeReadFileAsync("dir", "file.txt")binds to that overload with"dir"as the version id; use theICloudFileStorageManagerinterface orReadFileVersionAsyncfor plain reads. - Request presigned download URLs for at most 7 days, the S3 limit for signature version 4. The validity is not capped by the library: for a longer validity the AWS SDK falls back to a legacy signature version 2 URL, which buckets and regions without signature version 2 support reject.
- Path segments
.and..are rejected. - The configured root directory itself cannot be deleted, moved or overwritten.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- AWSSDK.S3 (>= 4.0.104.8)
- Cloud.File.Storage.Manager.Common (>= 4.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
- Targets .NET 10, AWS SDK for .NET v4 (AWSSDK.S3 4.0.104.8)
- Checksums are computed and validated only where S3 requires them, so S3 compatible servers keep working
- Presigned download URLs use http when the endpoint is http
- Requires Cloud.File.Storage.Manager.Common 4.0.0