BeeQ.FileStorage
1.4.0
dotnet add package BeeQ.FileStorage --version 1.4.0
NuGet\Install-Package BeeQ.FileStorage -Version 1.4.0
<PackageReference Include="BeeQ.FileStorage" Version="1.4.0" />
<PackageVersion Include="BeeQ.FileStorage" Version="1.4.0" />
<PackageReference Include="BeeQ.FileStorage" />
paket add BeeQ.FileStorage --version 1.4.0
#r "nuget: BeeQ.FileStorage, 1.4.0"
#:package BeeQ.FileStorage@1.4.0
#addin nuget:?package=BeeQ.FileStorage&version=1.4.0
#tool nuget:?package=BeeQ.FileStorage&version=1.4.0
BeeQ.FileStorage
Lightweight, extensible file storage builder for .NET. BeeQ.FileStorage provides a small fluent API to configure how files are identified, uploaded and retrieved. It includes helpers to store files on local disk and a builder that allows registering custom upload and retrieval handlers.
Supported targets: .NET 6, .NET 7, .NET 8, .NET 9, .NET 10
Features
- Fluent builder to configure file id creation, filename mapping and storage paths
- Upload handlers for Stream, byte[] and base64 string payloads
- Retrieval handlers returning Stream, byte[] or base64 string
- Local disk convenience extension (UseLocalDisk)
- Built-in or extensible support for multiple storage transports: Local Disk, FTP, FTPS and WebDAV
Installation
Install the NuGet package:
dotnet add package BeeQ.FileStorage
Quick Start
This example shows configuring a storage instance, uploading a file and retrieving it as a stream.
using BeeQ.FileStorage;
// Example setup
var contentBase64 = "..."; // base64 content
var database = ...;
// Configure a custom storage for GUID ids
var logos = Storage.Use<Guid>("logos")
.UseCustomFullPath(info => $"logos/{DateTime.Now:yyyy/MM}/{info.Filename}")
// Optionally map an id back to a filename
.OnGetFilename(id => database.ObtenerFilename(id))
// Handle upload when content is provided as a Stream
.OnUploadStream(async info =>
{
using FileStream file = File.Create(info.FullPath);
await info.Content.CopyToAsync(file);
})
// Provide how to open stored content as a stream
.OnGetStream(async info => File.Open(info.FullPath, FileMode.Open))
.Build();
// Upload (base64 example)
var id = await logos.Upload("coca-cola.png", contentBase64);
// Retrieve stream
var stream = await logos.GetStream(id);
Local disk convenience
BeeQ.FileStorage includes a convenience extension to quickly configure a local-disk-backed storage:
var imagenes = Storage.Create().UseLocalDisk("imagenes", "C:\\");
var id = await imagenes.Upload("coca-cola.png", contentBase64);
var stream = await imagenes.GetStream(id);
This extension sets up sensible defaults and a deterministic id generation using MD5 of schema+filename (GUID).
Note on other transports
The library is designed to be transport-agnostic. In addition to the Local Disk convenience extension, BeeQ.FileStorage can be used with remote storage transports such as FTP, FTPS and WebDAV. These transports can be integrated either by using provider-specific extensions (if available) or by registering custom upload and retrieval handlers with the builder (OnUpload*/OnGet* handlers).
API overview
- Storage: static entry point
- Storage.Use<TId>(schemaKey) → IFileStorageBuilder<TId>
- Storage.Create() → IFileStorageBuilder
- IFileStorageBuilder<TId>
- UseStandardFullPath(), UseCustomFullPath(Func<IFileStorageFullIdentifier<TId>, string>)
- OnUploadStream/OnUploadBytes/OnUploadBase64(...) to register upload handlers
- OnGetStream/OnGetBytes/OnGetBase64(...) to register retrieval handlers
- OnCreateId(Func<(string? SchemaName, string Filename), Task<TId>>) to provide id creation
- Build() → IFileStorage<TId>
- IFileStorage<TId>
- Upload(filename, content) overloads for base64, byte[] and Stream
- GetStream/GetBytes/GetBase64 to retrieve stored content
Refer to the XML documentation in the library for more details on interfaces and members.
Integration notes
- The library is lightweight and does not enforce a DI registration model. You may create storage instances at startup and register them in your DI container if desired.
- Ensure your upload handlers manage streams and resources correctly (dispose or copy streams when required).
Contributing
Contributions are welcome. Please open issues or pull requests on the repository. Follow the existing code style and include tests where appropriate.
License
See the LICENSE file in this repository.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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
- No dependencies.
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (5)
Showing the top 5 NuGet packages that depend on BeeQ.FileStorage:
| Package | Downloads |
|---|---|
|
BeeQ.FileStorage.AWSS3
Simplifies the storage of files in AWS S3 as Extension of BeeQ.FileStorage |
|
|
BeeQ.FileStorage.AzureBlob
Simplifies the storage of files in Azure Blob Storage as Extension of BeeQ.FileStorage |
|
|
BeeQ.FileStorage.GoogleCloud
Simplifies the storage of files in Google Cloud Storage as Extension of BeeQ.FileStorage |
|
|
BeeQ.FileStorage.GoogleDrive
Simplifies the storage of files in Google Drive as Extension of BeeQ.FileStorage |
|
|
BeeQ.FileStorage.OneDrive
Simplifies the storage of files in Microsoft One Drive as Extension of BeeQ.FileStorage |
GitHub repositories
This package is not used by any popular GitHub repositories.