Promact.FileService.Abstractions 2.0.0

dotnet add package Promact.FileService.Abstractions --version 2.0.0
                    
NuGet\Install-Package Promact.FileService.Abstractions -Version 2.0.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="Promact.FileService.Abstractions" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Promact.FileService.Abstractions" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Promact.FileService.Abstractions" />
                    
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 Promact.FileService.Abstractions --version 2.0.0
                    
#r "nuget: Promact.FileService.Abstractions, 2.0.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 Promact.FileService.Abstractions@2.0.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=Promact.FileService.Abstractions&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Promact.FileService.Abstractions&version=2.0.0
                    
Install as a Cake Tool

file-service

File Service is a versatile repository facilitating seamless file uploads to cloud storage providers such as AWS S3, Azure. IFileService<TFileModel> is generic over the provider's file model type, so the compiler — not a runtime check — enforces that you're using the file model that matches your registered provider. Developed with modularity and ease of integration in mind.

Usage

Inject IFileService<S3FileModel> (AWS) or IFileService<AzureBlobFileModel> (Azure) — whichever matches the provider you registered in DI (see the AWS/Azure sections below). IFileService<TFileModel>, FileModelBase, and GetAllKeysRequest live in Promact.FileService.Abstractions; S3FileModel is in Promact.FileService.AWS and AzureBlobFileModel is in Promact.FileService.Azure.

using Promact.FileService.Abstractions;
using Promact.FileService.AWS; // or Promact.FileService.Azure

private IFileService<S3FileModel> _fileService // or IFileService<AzureBlobFileModel> for Azure

public async Task MyMethod()
{
    // For AWS:
    var fileModel = new S3FileModel
    {
        BucketName = "my_Bucket",
        KeyName = "FileName",
        FilePath = "path/to/file.txt"
    };

    // For Azure, use an AzureBlobFileModel instead:
    // var fileModel = new AzureBlobFileModel
    // {
    //     ContainerName = "my_container",
    //     KeyName = "FileName",
    //     FilePath = "path/to/file.txt"
    // };

    // Call the FileService method to upload the file
    await _fileService.UploadFileAsync(fileModel);

    // Call the FileService method to check whether the file exists
    var exists = await _fileService.CheckFileExistsAsync(fileModel);

    // Call the FileService method to get the content of the file as a byte array
    var fileBytes = await _fileService.GetFileAsBytesAsync(fileModel);

    // Call the FileService method to delete the file
    await _fileService.DeleteFileAsync(fileModel);

    // In the Case of Azure You get the Link by GetSignedUrlAsync method but you did not have 
    // permission to Acess So for Acess You Go Azure Portal >> Your storage  >> Settings
    // >> Configuration >> Allow Blob anonymous access >> Enabled
    // Then After >> Your Container >>  Change Access Level >> Blob (Read Only)

    // Call the FileService method  with expiration time to Get  the  url of file
    TimeSpan expiration = TimeSpan.FromHours(1);
    var signedUrl = await _fileService.GetSignedUrlAsync(fileModel, expiration);

    //Describe the pageno and pagesize for retriving keys in particular page

    var request = new GetAllKeysRequest
    {
        BucketOrContainer = "my_container",
        PageNumber = pgno,
        PageSize = Size_of_one_page,
    };

    var keys = await _fileService.GetKeysAsync(request);

    //foreach (var key in keys)
    //{
    //    Console.WriteLine(key);
    //}
}

Every method above also accepts an optional trailing CancellationToken.

AWS

Add nuget package

Promact.FileService.AWS

ASP.NET Core projects

Add below in Program.cs

 builder.Services.AddAWSFileService(options =>
 {
     options.AccessKey = Configuration.GetSection("AWS:AccessKeyId").Value;
     options.SecretKey = Configuration.GetSection("AWS:SecretAccessKey").Value;
     options.Region = Configuration.GetSection("AWS:Region").Value;
 });

Add relevant appsettings.json values

"AWS": {
    "AccessKeyID": "",
    "SecretAccessKey": "",
    "Region":  ""
}

Inject IFileService<S3FileModel> in class constructor from where you want to perform various files operation.

public MyClass(IFileService<S3FileModel> fileService)
{
...
}

Azure

Add nuget package

Promact.FileService.Azure

ASP.NET Core projects

Add below in Program.cs

// Register BlobServiceClient
builder.Services.AddAzureFileService(options =>
{
    options.ConnectionString = Configuration.GetSection("Azure:ConnectionString").Value;
});

Add relevant appsettings.json values

 "Azure": {
   "ConnectionString": ""
 },

Inject IFileService<AzureBlobFileModel> in class constructor from where you want to perform various files operation.

public MyClass(IFileService<AzureBlobFileModel> fileService)
{
...
}
Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

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
2.0.0 99 7/25/2026
1.0.0 96 7/25/2026