Naravel.Filesystem
0.2.0
dotnet add package Naravel.Filesystem --version 0.2.0
NuGet\Install-Package Naravel.Filesystem -Version 0.2.0
<PackageReference Include="Naravel.Filesystem" Version="0.2.0" />
<PackageVersion Include="Naravel.Filesystem" Version="0.2.0" />
<PackageReference Include="Naravel.Filesystem" />
paket add Naravel.Filesystem --version 0.2.0
#r "nuget: Naravel.Filesystem, 0.2.0"
#:package Naravel.Filesystem@0.2.0
#addin nuget:?package=Naravel.Filesystem&version=0.2.0
#tool nuget:?package=Naravel.Filesystem&version=0.2.0
Naravel.Filesystem
Named storage drivers for Naravel, built on Naravel.Foundation: local files and Amazon S3 / S3-compatible storage.
| Fact | Detail |
|---|---|
| Install | dotnet add package Naravel.Filesystem |
| Targets | .NET 10 |
| Needs | Naravel.Foundation, which NuGet installs with it (the S3 driver uses AWSSDK.S3) |
| Drivers | local (a folder) and s3 (Amazon S3 or S3-compatible storage) |
What you get
- Named disks. Configure as many
localands3stores as you need and pick one by name. - One API for files and S3. The same
IStorageDrivercalls work on a local folder and on a bucket. - Presigned S3 URLs. An S3 disk returns a presigned URL from
GetUrlAsync. - Safe local paths. A path cannot leave the disk root.
- A test fake.
StorageFakeinNaravel.Filesystem.Testingis an in-memoryIStorageDriver.
Quick start
{
"Filesystem": {
"Default": "local",
"Stores": {
"local": { "Driver": "local", "Root": "wwwroot/uploads", "BaseUrl": "/storage" },
"archive": { "Driver": "s3", "Bucket": "my-archive", "Region": "eu-west-1" }
}
}
}
using Naravel.Filesystem;
builder.Services.AddNaravelFilesystem(builder.Configuration);
app.MapPost("/uploads", async (HttpRequest request, IStorageDriver storage, CancellationToken ct) =>
{
var path = $"reports/{Guid.NewGuid():N}.bin"; // a name you choose, not one taken from the request
await storage.PutAsync(path, request.Body, ct);
return Results.Ok(await storage.GetUrlAsync(path, cancellationToken: ct));
});
The disk names (local, archive) and the bucket are yours. IStorageDriver is the default disk; inject StorageManager and call Disk("archive") for another. An S3 disk requires Bucket, Key and Secret (a missing one throws ArgumentNullException when the disk is first used); Region and Endpoint are optional. Keep Key and Secret out of the file and set them in the environment, for example Filesystem__Stores__archive__Key and Filesystem__Stores__archive__Secret.
For the local driver GetUrlAsync returns a URL under BaseUrl, unsigned and without an expiry; the expiration argument matters only for S3 presigned URLs. The local driver creates no HTTP endpoint, so serve the files with ASP.NET Core static files or an authorized download endpoint of your own. A path that leaves Root, through .. or a symbolic link, is rejected with UnauthorizedAccessException.
Learn more
- Filesystem: English guide
- Changelog · Source and issues · MIT license
Part of Naravel: Laravel's names, .NET's type system. All Naravel packages share one version.
| 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.11)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.14)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Options (>= 10.0.14)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.14)
- Naravel.Foundation (>= 0.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Release notes: https://github.com/km-arc/Naravel/releases/tag/v0.2.0 - full history: https://github.com/km-arc/Naravel/blob/main/CHANGELOG.md