NetNinja.AzureStorageHandler
1.0.6
dotnet add package NetNinja.AzureStorageHandler --version 1.0.6
NuGet\Install-Package NetNinja.AzureStorageHandler -Version 1.0.6
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="NetNinja.AzureStorageHandler" Version="1.0.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NetNinja.AzureStorageHandler" Version="1.0.6" />
<PackageReference Include="NetNinja.AzureStorageHandler" />
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 NetNinja.AzureStorageHandler --version 1.0.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: NetNinja.AzureStorageHandler, 1.0.6"
#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 NetNinja.AzureStorageHandler@1.0.6
#: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=NetNinja.AzureStorageHandler&version=1.0.6
#tool nuget:?package=NetNinja.AzureStorageHandler&version=1.0.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
AzureStorageHandler
Usage
¿ How to inject ?
//program.cs
var storageConfiguration = new StorageConfiguration
{
BlobName = "myblob",
ContainerName = builder.Configuration["AzureStorage:StgContainerName"] ?? string.Empty,
ConnectionString = builder.Configuration["AzureStorage:StgConnectionString"] ?? string.Empty,
FilePath = builder.Configuration["AzureStorage:Uri"] ?? string.Empty,
ExpiresOnInHours = Int32.Parse(builder.Configuration["AzureStorage:ExpiresOnInHours"]!)
};
builder.Services.AddSingleton(storageConfiguration);
builder.Services.AddSingleton(x => new BlobServiceClient(
builder.Configuration["AzureStorage:StgConnectionString"] ?? string.Empty
)
);
builder.Services.AddTransient<IStorageHandler, StorageHandler>();
Terms:
ConnectionString : connection string of your storage account
BlobName : you don't need to set here, you will when you use then methods to upload
ContainerName : you can set here one by default or set in uploads methods dynamically.
FilePath : the path to your container
ExpiresOnInHours : the time a sasUri takes to expire.
Blob Methods
- UploadIFormFileToBlobAsync: Upload a file as multipart it will return a blobReference with blob info with a sasUri included
var blobReference = await _storageHandler.UploadIFormFileToBlobAsync(multipartFile);
return blobReference;
- Uploadbase64BlobAsync Upload a file as base64 it will return a blobReference with blob info with a sasUri included
var blobReference = await _storageHandler.Uploadbase64BlobAsync(base64Command);
return blobReference;
- GenerateSasUriFromBlobName generate a sasUri
_storageHandler.GenerateSasUriFromBlobName(blobName);
- GetContainersInBlobs get the blobs in a given container
_storageHandler.ListAllBlobs(containerName);
Container Methods
- CreateContainer create a new container
CreateContainer
- DeleteContainer 🚨🚨delete container🚨🚨
_storageHandler.DeleteContainer(containerName);
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
- Azure.Storage.Blobs (>= 12.23.0-beta.2)
- FluentValidation (>= 11.10.0)
- FluentValidation.DependencyInjectionExtensions (>= 11.10.0)
- Microsoft.AspNetCore.Http.Features (>= 5.0.17)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.