Core Reference
Kanject.Core.FileRepository
S3 wrapper with content-type detection, presigned URLs, and access-level helpers. Treat object storage as a typed key/value store with stream-friendly read and write methods.
Install
dotnet add package Kanject.Core.FileRepository Register
using Kanject.Core.FileRepository.Provider.S3.Extensions;
builder.Services.AddS3FileRepository(options =>
{
options.Bucket = appSettings.UploadsBucket;
options.AwsRegion = appSettings.AwsRegion;
options.UrlExpiry = TimeSpan.FromMinutes(10); // default for signed URLs
}); Use it
public class AvatarService(IFileRepository files)
{
public async Task<string> UploadAsync(Guid userId, Stream content, string contentType)
{
var key = $"users/{userId}/avatar";
await files.WriteAsync(key, content, new WriteOptions
{
ContentType = contentType,
CacheControl = "public, max-age=86400",
Access = AccessLevel.Public,
});
return files.GetPublicUrl(key);
}
public Task<string> GetSignedDownloadAsync(string invoiceKey)
=> files.GetSignedUrlAsync(invoiceKey, TimeSpan.FromHours(1));
} What ships with it
WriteAsync/ReadAsync/DeleteAsync/ExistsAsyncover a single bucket- Presigned URL generation for both upload and download
AccessLevel(public / private / signed) baked into write options- Per-object metadata + tag support
- Multi-part upload for streams above the 5 MB threshold
Pair with
For a managed file-server experience (CDN, virus scanning, versioning, RBAC), see [Kanject.FileServer](/baas/fileserver) — it builds on this library and adds the operational layer.