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" />
                    
Directory.Packages.props
<PackageReference Include="NetNinja.AzureStorageHandler" />
                    
Project file
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
                    
#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
                    
Install as a Cake Addin
#tool nuget:?package=NetNinja.AzureStorageHandler&version=1.0.6
                    
Install as a Cake Tool

File storage image

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

  1. 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;     
  1. 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;
  1. GenerateSasUriFromBlobName generate a sasUri
    _storageHandler.GenerateSasUriFromBlobName(blobName);
  1. GetContainersInBlobs get the blobs in a given container
    _storageHandler.ListAllBlobs(containerName);

Container Methods

  1. CreateContainer create a new container
    CreateContainer
  1. DeleteContainer 🚨🚨delete container🚨🚨
   _storageHandler.DeleteContainer(containerName);
Product 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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.6 105 11/13/2024
1.0.5 79 11/8/2024
1.0.4 77 11/8/2024
1.0.3 78 11/7/2024
1.0.2 74 11/7/2024
1.0.1 79 11/7/2024