TAF.FileManager.SDK
1.2.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package TAF.FileManager.SDK --version 1.2.0
NuGet\Install-Package TAF.FileManager.SDK -Version 1.2.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TAF.FileManager.SDK" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TAF.FileManager.SDK" Version="1.2.0" />
<PackageReference Include="TAF.FileManager.SDK" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TAF.FileManager.SDK --version 1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TAF.FileManager.SDK, 1.2.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TAF.FileManager.SDK@1.2.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TAF.FileManager.SDK&version=1.2.0
#tool nuget:?package=TAF.FileManager.SDK&version=1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
TAF.FileManager.SDK
HTTP-based SDK for TAF FileManager Service. Provides BusContext extension methods for fetching images as streams, designed for Base64 image embedding in PDF reports.
Installation
dotnet add package TAF.FileManager.SDK
Features
context.GetImageAsync(path)extension methodcontext.GetImageAsBase64Async(path)for direct Base64 conversion- Graceful 404 handling (returns null, no exception)
- Context header propagation (TenantId, AppId, EnvironmentId)
- Follows same pattern as TAF.MetaData.SDK
Setup
1. Register Services (Program.cs)
// Option 1: Using configuration
builder.Services.AddFileManagerClient(builder.Configuration);
// Option 2: Using manual options
builder.Services.AddFileManagerClient(options =>
{
options.BaseUrl = "https://localhost:44341";
options.TimeoutSeconds = 30;
});
2. Initialize Extensions (Program.cs)
var app = builder.Build();
// Initialize after building the service provider
app.Services.InitializeFileManagerExtensions();
3. Configuration (appsettings.json)
{
"FileManagerService": {
"BaseUrl": "https://localhost:44341",
"Timeout": 30
}
}
Usage
Get Image as Stream
// In any service/handler with BusContext
var imageStream = await context.GetImageAsync("/uploads/logo.png");
if (imageStream != null)
{
using var memoryStream = new MemoryStream();
await imageStream.CopyToAsync(memoryStream);
var base64 = Convert.ToBase64String(memoryStream.ToArray());
// Use in PDF, HTML, etc.
var imgSrc = $"data:image/png;base64,{base64}";
}
Get Image as Base64 (Convenience Method)
// Direct Base64 conversion
var base64Image = await context.GetImageAsBase64Async("/uploads/logo.png");
if (base64Image != null)
{
var imgSrc = $"data:image/png;base64,{base64Image}";
}
With Image Type
// Get icon type image
var iconStream = await context.GetImageAsync("/icons/user.png", type: "Icon");
// Get with record ID
var recordImage = await context.GetImageAsync("/images/profile.png", recordId: "12345");
Error Handling
- 404 Not Found: Returns
null(graceful handling) - Network Errors: Throws
HttpRequestException - Timeout: Throws
TimeoutException - Cancelled: Throws
OperationCanceledException
try
{
var imageStream = await context.GetImageAsync("/uploads/logo.png");
if (imageStream == null)
{
// Image not found - use default or skip
_logger.LogWarning("Image not found: /uploads/logo.png");
}
}
catch (HttpRequestException ex)
{
_logger.LogError(ex, "Failed to fetch image from FileManager");
}
API Reference
BusContext Extensions
| Method | Description | Returns |
|---|---|---|
GetImageAsync(path, type?, recordId?, ct?) |
Get image as stream | Task<Stream?> |
GetImageAsBase64Async(path, type?, recordId?, ct?) |
Get image as Base64 | Task<string?> |
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
path |
string |
required | Path to the image file |
type |
string |
"Standard" | Image type ("Standard", "Icon", etc.) |
recordId |
string? |
null | Optional record ID |
cancellationToken |
CancellationToken |
default | Cancellation token |
Version History
- 1.0.0: Initial release with GetImageAsync and GetImageAsBase64Async extension methods
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 was computed. 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 was computed. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.8)
- Microsoft.Extensions.DependencyInjection (>= 9.0.8)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.8)
- Microsoft.Extensions.Http (>= 9.0.8)
- Microsoft.Extensions.Options (>= 9.0.8)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.8)
- TAF.Infra.Contract (>= 1.10.5)
- TAF.Infra.MassTransit (>= 2.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.