Skip to content

Add FileSystem Storage Provider - #78

Merged
marcominerva merged 2 commits into
masterfrom
develop
Sep 9, 2026
Merged

marcominerva merged 2 commits into
masterfrom
develop

Conversation

@marcominerva

Copy link
Copy Markdown
Owner

No description provided.

Implemented FileSystemStorageProvider with DI, config, and JSON support under src/StorageProviders.FileSystem. Added sample ASP.NET Core project demonstrating usage. Updated README with docs, added solution/project files, versioning, and GitHub Actions workflow for publishing. Included Capanno.jpg and minor sample improvements.
README.md reorganized for clarity: File System section moved before Azure Storage, with new badges, install steps, DI registration, and detailed usage/security notes. Azure Storage docs restructured for consistency, with clearer headings, install/usage instructions, and more code samples. Expanded metadata and provider behavior explanations. Improves onboarding and discoverability for both providers.
Copilot AI lite review requested due to automatic review settings September 9, 2026 14:15
@marcominerva
marcominerva merged commit 3dfdae9 into master Sep 9, 2026
5 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new file-system provider has confirmed contract/security issues (missing-object reads throw instead of returning null, file URI creation can be relative on Unix, and internal metadata I/O lacks reparse-point validation).

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR introduces a new local file-system backed IStorageProvider implementation, wires it into the solution and packaging workflow, and documents/illustrates its usage via a new sample and README updates.

Changes:

  • Added StorageProviders.FileSystem library (provider + DI extensions + settings + source-gen JSON metadata support).
  • Added FileSystemSample ASP.NET Core minimal API sample demonstrating file operations and metadata.
  • Updated solution, README, and GitHub Actions workflow to build/publish the new provider.
File summaries
File Description
StorageProviders.slnx Adds the new provider and sample projects to the solution.
src/StorageProviders.FileSystem/version.json Sets up NerdBank.GitVersioning for the new package.
src/StorageProviders.FileSystem/StorageProviders.FileSystem.xml Adds generated XML doc output for the new assembly.
src/StorageProviders.FileSystem/StorageProviders.FileSystem.csproj Defines multi-targeting and packaging metadata for the new provider.
src/StorageProviders.FileSystem/FileSystemStorageSettings.cs Introduces the settings object (root directory).
src/StorageProviders.FileSystem/FileSystemStorageProviderExtensions.cs Adds DI registration entry points for the new provider.
src/StorageProviders.FileSystem/FileSystemStorageProvider.cs Implements file-system storage operations + metadata sidecars.
src/StorageProviders.FileSystem/FileSystemJsonSerializerContext.cs Adds source-generated JSON serialization for metadata.
samples/FileSystemSample/Program.cs Demonstrates API usage via minimal endpoints.
samples/FileSystemSample/Models/UploadFileWithMetadataRequest.cs Defines the multipart upload + metadata request model.
samples/FileSystemSample/FileSystemSample.csproj Adds a runnable sample referencing the new provider project.
samples/FileSystemSample/* (appsettings, http, launchSettings) Provides configuration and request examples for the sample.
samples/AzureStorageSample/Program.cs Adjusts Swagger UI mapping call style for consistency.
README.md Documents the new provider (installation, registration, behavior, usage).
.github/workflows/publish_filesystem.yml Adds NuGet publishing workflow for the new provider package.
Review details

Files not reviewed (1)

  • src/StorageProviders.FileSystem/StorageProviders.FileSystem.xml: Generated file

Suppressed comments (2)

src/StorageProviders.FileSystem/FileSystemStorageProvider.cs:256

  • WriteMetadataAsync writes to metadataPath without validating that the target path doesn't contain reparse points. This should apply the same reparse-point checks as the main file I/O to keep the storage root as the security boundary.
        Directory.CreateDirectory(metadataDirectory);

        await using var stream = new FileStream(metadataPath, FileMode.Create, FileAccess.Write, FileShare.None, bufferSize: 4096, FileOptions.Asynchronous);
        await JsonSerializer.SerializeAsync(stream, new FileSystemMetadata(metadata), FileSystemJsonSerializerContext.Default.FileSystemMetadata, cancellationToken).ConfigureAwait(false);

src/StorageProviders.FileSystem/FileSystemStorageProvider.cs:263

  • DeleteMetadata deletes the sidecar JSON without any reparse-point validation. If .storageproviders/metadata were replaced with a symlink, this could delete arbitrary files outside the storage root.
    private void DeleteMetadata(string path)
    {
        if (Directory.Exists(metadataDirectory))
        {
            File.Delete(GetMetadataPath(path));
  • Files reviewed: 17/19 changed files
  • Comments generated: 5
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +23 to +27
rootDirectory = Path.GetFullPath(settings.RootDirectory);
metadataDirectory = Path.Combine(rootDirectory, ProviderDirectoryName, MetadataDirectoryName);

Directory.CreateDirectory(rootDirectory);
}
Comment on lines +229 to +238
private async Task<IDictionary<string, string?>> ReadMetadataAsync(string path, CancellationToken cancellationToken)
{
var metadataPath = GetMetadataPath(path);
if (!File.Exists(metadataPath))
{
return new FileSystemMetadata();

}

await using var stream = new FileStream(metadataPath, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize: 4096, FileOptions.Asynchronous | FileOptions.SequentialScan);
Comment on lines +56 to +64
public Task<Stream?> ReadAsStreamAsync(string path, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();

var fullPath = GetExistingFilePath(path);

var stream = new FileStream(fullPath, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize: 81920, FileOptions.Asynchronous | FileOptions.SequentialScan);
return Task.FromResult<Stream?>(stream);
}
Comment on lines +93 to +106
foreach (var filePath in Directory.EnumerateFiles(rootDirectory, "*", enumerationOptions))
{
cancellationToken.ThrowIfCancellationRequested();

var logicalPath = Path.GetRelativePath(rootDirectory, filePath).Replace(Path.DirectorySeparatorChar, '/');
if (logicalPath.StartsWith($"{ProviderDirectoryName}/", StringComparison.OrdinalIgnoreCase) || (normalizedPrefix is not null && !logicalPath.StartsWith(normalizedPrefix, GetPathComparison()))
|| (extensionSet.Count > 0 && !extensionSet.Contains(Path.GetExtension(filePath))))
{
continue;
}

yield return logicalPath;
await Task.Yield();
}
Comment on lines +137 to +145
public Task<Uri> GetFullPathAsync(string path, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();

var fullPath = GetFullPath(path);
EnsureNoReparsePoints(fullPath);

return Task.FromResult(new Uri(fullPath));
}
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.

2 participants