![]() |
VOOZH | about |
dotnet add package Omnia.FileAzure --version 10.0.1
NuGet\Install-Package Omnia.FileAzure -Version 10.0.1
<PackageReference Include="Omnia.FileAzure" Version="10.0.1" />
<PackageVersion Include="Omnia.FileAzure" Version="10.0.1" />Directory.Packages.props
<PackageReference Include="Omnia.FileAzure" />Project file
paket add Omnia.FileAzure --version 10.0.1
#r "nuget: Omnia.FileAzure, 10.0.1"
#:package Omnia.FileAzure@10.0.1
#addin nuget:?package=Omnia.FileAzure&version=10.0.1Install as a Cake Addin
#tool nuget:?package=Omnia.FileAzure&version=10.0.1Install as a Cake Tool
Questo file documenta le API pubbliche esposte dal progetto Omnia.FileAzure. Contiene i namespace, le interfacce e le classi principali, con la descrizione dei metodi pubblici e esempi d'uso.
Namespaces
Omnia.FileAzure.Interfaces — interfacce pubbliche per i servizi di file/Blob.Omnia.FileAzure.Implementations — implementazioni concrete fornite dal package.Interfacce (namespace Omnia.FileAzure.Interfaces)
IBlobConfig
string ConnectionString { get; } — connection string per Azure Storage.string ContainerName { get; } — nome del container blob da usare.IPrivateFile<IdFile>
Task<string> UploadFileAsync(IFormFile file)
file su blob storage e restituisce l'id/nome del blob caricato.Task<Stream> GetFileAsync(IdFile id)
id e restituisce uno Stream con i dati.Task DeleteFileAsync(IdFile id)
id.IFileRepository<IdFile> : IPrivateFile<IdFile> — repository che implementa l'accesso diretto allo storage.
IFileService<IdFile> : IPrivateFile<IdFile> — servizio che incapsula la logica attorno al repository.
IFileUpperService<IdFile> : IFileService<IdFile> — upper service che aggiunge hook before/after.
IFileBeforeService<in IdFile>
Task UploadFileAsync(IFormFile file) — chiamato prima dell'upload principale.Task GetFileAsync(IdFile id) — chiamato prima del get.Task DeleteFileAsync(IdFile id) — chiamato prima della delete.IFileAfterService<in IdFile>
Task UploadFileAsync(IFormFile file, IdFile idFile) — chiamato dopo l'upload principale e riceve l'id risultato.Task AfterGetFileAsync(IdFile id, Stream file) — chiamato dopo il get con lo stream restituito.Task AfterDeleteFileAsync(IdFile id) — chiamato dopo la delete.Implementazioni (namespace Omnia.FileAzure.Implementations)
BlobConfig : IBlobConfig
BlobConfig(IConfiguration configuration)
Blob:ConnectionString e Blob:ContainerName da IConfiguration.ConnectionString — ritorna la connection string o string.Empty se non presente.ContainerName — ritorna il container name o string.Empty se non presente.BlobRepository : IFileRepository<string>
BlobRepository(IBlobConfig blobConfig)
BlobServiceClient con blobConfig.ConnectionString e BlobContainerClient per blobConfig.ContainerName.Task<string> UploadFileAsync(IFormFile file)
FormFileID.CreateUniqueBlobNameAsync(file)), effettua UploadAsync e restituisce il blob name.Task<Stream> GetFileAsync(string blobName)
BlobClient, chiama DownloadAsync() e ritorna downloadInfo.Value.Content.Task DeleteFileAsync(string blobName)
BlobClient e chiama DeleteIfExistsAsync().BlobService : IFileService<string>
BlobService(IFileRepository<string> repository)Task<string> UploadFileAsync(IFormFile file) — delega a repository.UploadFileAsync.Task<Stream> GetFileAsync(string blobName) — delega a repository.GetFileAsync.Task DeleteFileAsync(string blobName) — delega a repository.DeleteFileAsync.BlobUpperService : IFileUpperService<string>
BlobUpperService(IFileService<string> service, IFileBeforeService<string> beforeService, IFileAfterService<string> afterService)UploadFileAsync(IFormFile file)
_beforeService.UploadFileAsync(file), poi _service.UploadFileAsync(file) e _afterService.UploadFileAsync(file, idFile).GetFileAsync(string blobName)
_beforeService.GetFileAsync(blobName), _service.GetFileAsync(blobName) e _afterService.AfterGetFileAsync(blobName, file).DeleteFileAsync(string blobName)
_beforeService.DeleteFileAsync(blobName), _service.DeleteFileAsync(blobName) e _afterService.AfterDeleteFileAsync(blobName).ServiceCollectionExtensions (static class)
IServiceCollection AddFileAzure(this IServiceCollection services, IConfiguration configuration, bool addDummies = true)
IBlobConfig come new BlobConfig(configuration) e i servizi/repository (BlobRepository, BlobService, BlobUpperService). Se addDummies è true, registra le implementazioni dummy per IFileBeforeService e IFileAfterService.IServiceCollection AddFileAzure(this IServiceCollection services, string connectionString, string containerName, bool addDummies = true)
IConfiguration): registra IBlobConfig (con valori passati) e gli altri servizi.Esempi d'uso
IConfiguration):using Omnia.FileAzure.Implementations;
var builder = WebApplication.CreateBuilder(args);
// Registra tutto leggendo da appsettings / environment
builder.Services.AddFileAzure(builder.Configuration);
var app = builder.Build();
builder.Services.AddFileAzure("UseDevelopmentStorage=true", "my-container");
Note operative
BlobConfig legge i valori da Blob:ConnectionString e Blob:ContainerName in IConfiguration.Azure.RequestFailedException) vengono propagate: gestiscile nel tuo codice chiamante.Before/After sono opzionali: il pacchetto fornisce no-op dummy se non registri implementazioni custom.Se vuoi, posso generare una sezione aggiuntiva che mostra esempi completi di appsettings.json, test di integrazione e un piccolo snippet per utilizzare il package in un'app console.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.