LiteX.Storage.Core 4.0.0

Abstract interface to implement any kind of basic blob storage services (e.g. Azure, Amazon, Google, Local FileSystem) for any type of application (ASP.NET Core, .Net Standard 2.x).

There is a newer version of this package available.
See the version list below for details.
Install-Package LiteX.Storage.Core -Version 4.0.0
dotnet add package LiteX.Storage.Core --version 4.0.0
<PackageReference Include="LiteX.Storage.Core" Version="4.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LiteX.Storage.Core --version 4.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

LiteXStorage

Abstract interface to implement any kind of basic blob storage services (e.g. Azure, Amazon, Google, Local FileSystem) for any type of application (ASP.NET Core, .Net Standard 2.x).

Add a dependency

Nuget

Run the nuget command for installing the client as,

  • Install-Package LiteX.Storage.Core
  • Install-Package LiteX.Storage.Azure
  • Install-Package LiteX.Storage.Amazon
  • Install-Package LiteX.Storage.Google
  • Install-Package LiteX.Storage.Local
  • Install-Package LiteX.Storage.Kvpbase

Configuration

AppSettings

{
  //LiteX Azure Storage settings
  "AzureBlobConfig": {
    "AzureBlobStorageConnectionString": "--- REPLACE WITH YOUR AZURE CONNECTION STRING ---",
    "AzureBlobStorageContainerName": "--- REPLACE WITH YOUR AZURE CONTAINER NAME ---",
    "AzureBlobStorageEndPoint": "--- REPLACE WITH YOUR AZURE END POINT ---"
  },

  //LiteX Amazon Storage settings
  "AmazonBlobConfig": {
    "AmazonAwsAccessKeyId": "--- REPLACE WITH YOUR AMAZON ACCESS KEY ID ---",
    "AmazonAwsSecretAccessKey": "--- REPLACE WITH YOUR AMAZON SECRET ACCESS KEY ---",
    "AmazonBucketName": "--- REPLACE WITH YOUR AZURE AMAZON BUCKET NAME ---"
  },

  //LiteX Google Storage settings
  "GoogleCloudBlobConfig": {
    "GoogleProjectId": "--- REPLACE WITH YOUR GOOGLE PROJECT ID ---",
    "GoogleJsonAuthPath": "--- REPLACE WITH YOUR GOOGLE JSON AUTH PATH ---",
    "GoogleBucketName": "--- REPLACE WITH YOUR GOOGLE BUCKET NAME ---"
  },

  //LiteX Kvpbase Storage settings
  "KvpbaseBlobConfig": {
    "KvpbaseApiKey": "--- REPLACE WITH YOUR KVPBASE API KEY ---",
    "KvpbaseContainer": "--- REPLACE WITH YOUR KVPBASE CONTAINER ---",
    "KvpbaseEndpoint": "--- REPLACE WITH YOUR KVPBASE END POINT ---",
    "KvpbaseUserGuid": "--- REPLACE WITH YOUR KVPBASE USERGUID ---"
  },

  //LiteX Local File System Storage settings
  "FileSystemBlobConfig": {
    "Directory": "--- REPLACE WITH YOUR LOCAL FILE SYSTEM DIRECTORY ---"
  }
}

Startup Configuration

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        #region LiteX Storage (Azure)

        // 1. Use default configuration from appsettings.json's 'AzureBlobConfig'
        services.AddLiteXAzureBlobService();

        //OR
        // 2. Load configuration settings using options.
        services.AddLiteXAzureBlobService(option =>
        {
            //option. = "";
        });

        //OR
        // 3. Load configuration settings on your own.
        // (e.g. appsettings, database, hardcoded)
        var azureBlobConfig = new AzureBlobConfig();
        services.AddLiteXAzureBlobService(azureBlobConfig);

        #endregion

        #region LiteX Storage (Amazon)

        // 1. Use default configuration from appsettings.json's 'AmazonBlobConfig'
        services.AddLiteXAmazonBlobService();

        //OR
        // 2. Load configuration settings using options.
        services.AddLiteXAmazonBlobService(option =>
        {
            //option. = "";
        });

        //OR
        // 3. Load configuration settings on your own.
        // (e.g. appsettings, database, hardcoded)
        var amazonBlobConfig = new AmazonBlobConfig();
        services.AddLiteXAmazonBlobService(amazonBlobConfig);

        #endregion

        #region LiteX Storage (Google)

        // 1. Use default configuration from appsettings.json's 'GoogleCloudBlobConfig'
        services.AddLiteXGoogleCloudBlobService();

        //OR
        // 2. Load configuration settings using options.
        services.AddLiteXGoogleCloudBlobService(option =>
        {
            //option. = "";
        });

        //OR
        // 3. Load configuration settings on your own.
        // (e.g. appsettings, database, hardcoded)
        var googleCloudBlobConfig = new GoogleCloudBlobConfig();
        services.AddLiteXGoogleCloudBlobService(googleCloudBlobConfig);

        #endregion

        #region LiteX Storage (Kvpbase)

        services.AddLiteXKvpbaseBlobService();

        services.AddLiteXKvpbaseBlobService(option =>
        {
            //option. = "";
        });

        var kvpbaseBlobConfig = new KvpbaseBlobConfig();
        services.AddLiteXKvpbaseBlobService(kvpbaseBlobConfig);

        #endregion

        #region LiteX Storage (FileSystem-Local)

        services.AddLiteXFileSystemBlobService();

        services.AddLiteXFileSystemBlobService(option =>
        {
            //option. = "";
        });

        var fileSystemBlobConfig = new FileSystemBlobConfig();
        services.AddLiteXFileSystemBlobService(fileSystemBlobConfig);

        #endregion
    }
}

Usage

Controller or Business layer

[Route("api/[controller]")]
public class CustomerController : Controller
{
    private readonly IBlobService _blobService;

    public CustomerController(IBlobService blobService)
    {
        _blobService = blobService;
    }

    public IActionResult UploadFile(IFormFile file)
    {
        string blobName = file.FileName;
        Stream stream = file.OpenReadStream();
        string contentType = file.ContentType;
        BlobProperties properties = new BlobProperties { ContentType = contentType };

        bool isUploaded = _blobService.UploadBlob(blobName, stream, properties);
        //bool isUploaded = await _blobService.UploadBlobAsync(blobName, stream, properties);

        return Ok();
    }

    public IActionResult GetBlobFile(string blobName)
    {
        Stream stream = _blobService.GetBlob(blobName);
        //Stream stream = await _blobService.GetBlobAsync(blobName);

        return Ok();
    }

    public IActionResult GetBlobUrl(string blobName)
    {
        string blobUrl = _blobService.GetBlobUrl(blobName);
        //string blobUrl = await _blobService.GetBlobUrlAsync(blobName);

        return Ok();
    }

    public IActionResult GetBlobSasUrl(string blobName)
    {
        string blobUrl = _blobService.GetBlobSasUrl(blobName, DateTimeOffset.UtcNow.AddHours(2), BlobUrlAccess.Read);
        //string blobUrl = await _blobService.GetBlobSasUrlAsync(blobName, DateTimeOffset.UtcNow.AddHours(2), BlobUrlAccess.Read);

        return Ok();
    }

    public IActionResult DeleteBlobFile(string blobName)
    {
        bool isDeleted = _blobService.DeleteBlob(blobName);
        //bool isDeleted = await _blobService.DeleteBlobAsync(blobName);

        return Ok();
    }

    public IActionResult GetBlobMetadata(string blobName)
    {
        BlobDescriptor blobDescriptor = _blobService.GetBlobDescriptor(blobName);
        //BlobDescriptor blobDescriptor =  await _blobService.GetBlobDescriptorAsync(blobName);
        var metadata = blobDescriptor.Metadata;

        return Ok();
    }

    public IActionResult SetBlobMetadata(string blobName)
    {
        IDictionary<string, string> metadata = new Dictionary<string, string>();

        BlobProperties properties = new BlobProperties()
        {
            ContentType = "",
            Metadata = metadata,
            ContentDisposition = "",
            Security = BlobSecurity.Public
        };

        bool isSet = _blobService.SetBlobProperties(blobName, properties);
        //bool isSet = await _blobService.SetBlobPropertiesAsync(blobName, properties);

        return Ok();
    }

    public IActionResult GetBlobs()
    {
        List<BlobDescriptor> blobs = _blobService.GetBlobs().ToList();
        //List<BlobDescriptor> blobs = await _blobService.GetBlobsAsync().ToList();

        return Ok();
    }
}

LiteXStorage

Abstract interface to implement any kind of basic blob storage services (e.g. Azure, Amazon, Google, Local FileSystem) for any type of application (ASP.NET Core, .Net Standard 2.x).

Add a dependency

Nuget

Run the nuget command for installing the client as,

  • Install-Package LiteX.Storage.Core
  • Install-Package LiteX.Storage.Azure
  • Install-Package LiteX.Storage.Amazon
  • Install-Package LiteX.Storage.Google
  • Install-Package LiteX.Storage.Local
  • Install-Package LiteX.Storage.Kvpbase

Configuration

AppSettings

{
  //LiteX Azure Storage settings
  "AzureBlobConfig": {
    "AzureBlobStorageConnectionString": "--- REPLACE WITH YOUR AZURE CONNECTION STRING ---",
    "AzureBlobStorageContainerName": "--- REPLACE WITH YOUR AZURE CONTAINER NAME ---",
    "AzureBlobStorageEndPoint": "--- REPLACE WITH YOUR AZURE END POINT ---"
  },

  //LiteX Amazon Storage settings
  "AmazonBlobConfig": {
    "AmazonAwsAccessKeyId": "--- REPLACE WITH YOUR AMAZON ACCESS KEY ID ---",
    "AmazonAwsSecretAccessKey": "--- REPLACE WITH YOUR AMAZON SECRET ACCESS KEY ---",
    "AmazonBucketName": "--- REPLACE WITH YOUR AZURE AMAZON BUCKET NAME ---"
  },

  //LiteX Google Storage settings
  "GoogleCloudBlobConfig": {
    "GoogleProjectId": "--- REPLACE WITH YOUR GOOGLE PROJECT ID ---",
    "GoogleJsonAuthPath": "--- REPLACE WITH YOUR GOOGLE JSON AUTH PATH ---",
    "GoogleBucketName": "--- REPLACE WITH YOUR GOOGLE BUCKET NAME ---"
  },

  //LiteX Kvpbase Storage settings
  "KvpbaseBlobConfig": {
    "KvpbaseApiKey": "--- REPLACE WITH YOUR KVPBASE API KEY ---",
    "KvpbaseContainer": "--- REPLACE WITH YOUR KVPBASE CONTAINER ---",
    "KvpbaseEndpoint": "--- REPLACE WITH YOUR KVPBASE END POINT ---",
    "KvpbaseUserGuid": "--- REPLACE WITH YOUR KVPBASE USERGUID ---"
  },

  //LiteX Local File System Storage settings
  "FileSystemBlobConfig": {
    "Directory": "--- REPLACE WITH YOUR LOCAL FILE SYSTEM DIRECTORY ---"
  }
}

Startup Configuration

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        #region LiteX Storage (Azure)

        // 1. Use default configuration from appsettings.json's 'AzureBlobConfig'
        services.AddLiteXAzureBlobService();

        //OR
        // 2. Load configuration settings using options.
        services.AddLiteXAzureBlobService(option =>
        {
            //option. = "";
        });

        //OR
        // 3. Load configuration settings on your own.
        // (e.g. appsettings, database, hardcoded)
        var azureBlobConfig = new AzureBlobConfig();
        services.AddLiteXAzureBlobService(azureBlobConfig);

        #endregion

        #region LiteX Storage (Amazon)

        // 1. Use default configuration from appsettings.json's 'AmazonBlobConfig'
        services.AddLiteXAmazonBlobService();

        //OR
        // 2. Load configuration settings using options.
        services.AddLiteXAmazonBlobService(option =>
        {
            //option. = "";
        });

        //OR
        // 3. Load configuration settings on your own.
        // (e.g. appsettings, database, hardcoded)
        var amazonBlobConfig = new AmazonBlobConfig();
        services.AddLiteXAmazonBlobService(amazonBlobConfig);

        #endregion

        #region LiteX Storage (Google)

        // 1. Use default configuration from appsettings.json's 'GoogleCloudBlobConfig'
        services.AddLiteXGoogleCloudBlobService();

        //OR
        // 2. Load configuration settings using options.
        services.AddLiteXGoogleCloudBlobService(option =>
        {
            //option. = "";
        });

        //OR
        // 3. Load configuration settings on your own.
        // (e.g. appsettings, database, hardcoded)
        var googleCloudBlobConfig = new GoogleCloudBlobConfig();
        services.AddLiteXGoogleCloudBlobService(googleCloudBlobConfig);

        #endregion

        #region LiteX Storage (Kvpbase)

        services.AddLiteXKvpbaseBlobService();

        services.AddLiteXKvpbaseBlobService(option =>
        {
            //option. = "";
        });

        var kvpbaseBlobConfig = new KvpbaseBlobConfig();
        services.AddLiteXKvpbaseBlobService(kvpbaseBlobConfig);

        #endregion

        #region LiteX Storage (FileSystem-Local)

        services.AddLiteXFileSystemBlobService();

        services.AddLiteXFileSystemBlobService(option =>
        {
            //option. = "";
        });

        var fileSystemBlobConfig = new FileSystemBlobConfig();
        services.AddLiteXFileSystemBlobService(fileSystemBlobConfig);

        #endregion
    }
}

Usage

Controller or Business layer

[Route("api/[controller]")]
public class CustomerController : Controller
{
    private readonly IBlobService _blobService;

    public CustomerController(IBlobService blobService)
    {
        _blobService = blobService;
    }

    public IActionResult UploadFile(IFormFile file)
    {
        string blobName = file.FileName;
        Stream stream = file.OpenReadStream();
        string contentType = file.ContentType;
        BlobProperties properties = new BlobProperties { ContentType = contentType };

        bool isUploaded = _blobService.UploadBlob(blobName, stream, properties);
        //bool isUploaded = await _blobService.UploadBlobAsync(blobName, stream, properties);

        return Ok();
    }

    public IActionResult GetBlobFile(string blobName)
    {
        Stream stream = _blobService.GetBlob(blobName);
        //Stream stream = await _blobService.GetBlobAsync(blobName);

        return Ok();
    }

    public IActionResult GetBlobUrl(string blobName)
    {
        string blobUrl = _blobService.GetBlobUrl(blobName);
        //string blobUrl = await _blobService.GetBlobUrlAsync(blobName);

        return Ok();
    }

    public IActionResult GetBlobSasUrl(string blobName)
    {
        string blobUrl = _blobService.GetBlobSasUrl(blobName, DateTimeOffset.UtcNow.AddHours(2), BlobUrlAccess.Read);
        //string blobUrl = await _blobService.GetBlobSasUrlAsync(blobName, DateTimeOffset.UtcNow.AddHours(2), BlobUrlAccess.Read);

        return Ok();
    }

    public IActionResult DeleteBlobFile(string blobName)
    {
        bool isDeleted = _blobService.DeleteBlob(blobName);
        //bool isDeleted = await _blobService.DeleteBlobAsync(blobName);

        return Ok();
    }

    public IActionResult GetBlobMetadata(string blobName)
    {
        BlobDescriptor blobDescriptor = _blobService.GetBlobDescriptor(blobName);
        //BlobDescriptor blobDescriptor =  await _blobService.GetBlobDescriptorAsync(blobName);
        var metadata = blobDescriptor.Metadata;

        return Ok();
    }

    public IActionResult SetBlobMetadata(string blobName)
    {
        IDictionary<string, string> metadata = new Dictionary<string, string>();

        BlobProperties properties = new BlobProperties()
        {
            ContentType = "",
            Metadata = metadata,
            ContentDisposition = "",
            Security = BlobSecurity.Public
        };

        bool isSet = _blobService.SetBlobProperties(blobName, properties);
        //bool isSet = await _blobService.SetBlobPropertiesAsync(blobName, properties);

        return Ok();
    }

    public IActionResult GetBlobs()
    {
        List<BlobDescriptor> blobs = _blobService.GetBlobs().ToList();
        //List<BlobDescriptor> blobs = await _blobService.GetBlobsAsync().ToList();

        return Ok();
    }
}

Release Notes

Async support.
     Re-write again from scratch.
     Added new methods (e.g. create/delete container, SasUrl, GetBlobDescriptor, GetBlobs, Get/Set BlobProperties).
     Core logic changes.
     Use data stream instead of byte array.
     One default container/bucket specific.

  • .NETStandard 2.0

    • No dependencies.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on LiteX.Storage.Core:

Package Downloads
LiteX.Storage.Amazon
This client library enables working with the Amazon S3 service for storing binary/blob/object data. A very simple Wrapper for the Amazon S3 to handle bucket instantiations. A library to abstract storing files to Amazon S3. Wrapper library is just written for the purpose to bring a new level of ease to the developers who deal with AmazonS3 integration with your system. LiteXStorage is simple yet powerful and very high-performance storage mechanism and incorporating both synchronous and asynchronous usage with some advanced usages of cloud storage which can help us to handle storage more easier! Provide Storage service for any type of application (.NET 5, .NET Core, .NET Standard). Very simple yet advanced configuration. Minimal (one line) code configuration is required. It provides possibility to upload files, upload the content of a folder inclusively subfolders, enumerate buckets/container, enumerate the content of a specific 'subfolder', delete buckets/container and delete files from specific subfolders.
LiteX.Storage.Local
This client library enables working with the Local FileSystem Blob service for storing binary/blob/object data. A very simple Wrapper for the Local FileSystem to handle directory instantiations. A library to abstract storing files to Local FileSystem. Wrapper library is just written for the purpose to bring a new level of ease to the developers who deal with FileSystem integration with your system. (Signed URL and Update Properties not implemented) LiteXStorage is simple yet powerful and very high-performance storage mechanism and incorporating both synchronous and asynchronous usage with some advanced usages of cloud storage which can help us to handle storage more easier! Provide Storage service for any type of application (.NET 5, .NET Core, .NET Standard). Very simple yet advanced configuration. Minimal (one line) code configuration is required. It provides possibility to upload files, upload the content of a folder inclusively subfolders, enumerate buckets/container, enumerate the content of a specific 'subfolder', delete buckets/container and delete files from specific subfolders.
LiteX.Storage.Azure
This client library enables working with the Microsoft Azure Blob Storage service for storing binary/blob/object data. A very simple Wrapper for the Azure Blob Storage to handle container instantiations. A library to abstract storing files to Microsoft Azure. Wrapper library is just written for the purpose to bring a new level of ease to the developers who deal with Azure integration with your system. LiteXStorage is simple yet powerful and very high-performance storage mechanism and incorporating both synchronous and asynchronous usage with some advanced usages of cloud storage which can help us to handle storage more easier! Provide Storage service for any type of application (.NET 5, .NET Core, .NET Standard). Very simple yet advanced configuration. Minimal (one line) code configuration is required. It provides possibility to upload files, upload the content of a folder inclusively subfolders, enumerate buckets/container, enumerate the content of a specific 'subfolder', delete buckets/container and delete files from specific subfolders.
LiteX.Storage.Google
This client library enables working with the Google Cloud Storage service for storing binary/blob/object data. A very simple Wrapper for the Google Cloud Storage to handle bucket instantiations. A library to abstract storing files to Google Cloud Storage. Wrapper library is just written for the purpose to bring a new level of ease to the developers who deal with Google Cloud integration with your system. LiteXStorage is simple yet powerful and very high-performance storage mechanism and incorporating both synchronous and asynchronous usage with some advanced usages of cloud storage which can help us to handle storage more easier! Provide Storage service for any type of application (.NET 5, .NET Core, .NET Standard). Very simple yet advanced configuration. Minimal (one line) code configuration is required. It provides possibility to upload files, upload the content of a folder inclusively subfolders, enumerate buckets/container, enumerate the content of a specific 'subfolder', delete buckets/container and delete files from specific subfolders.
LiteX.Storage.Kvpbase
DEPRECATED (drops support for this package) This client library enables working with the Kvpbase Blob service for storing binary/blob/object data. A very simple Wrapper for the Kvpbase to handle bucket instantiations. A library to abstract storing files to Kvpbase. Wrapper library is just written for the purpose to bring a new level of ease to the developers who deal with Kvpbase integration with your system. (Signed URL and Update Properties and many other methods are not implemented) LiteXStorage is simple yet powerful and very high-performance storage mechanism and incorporating both synchronous and asynchronous usage with some advanced usages of cloud storage which can help us to handle storage more easier! Provide Storage service for any type of application (.NET 5, .NET Core, .NET Standard). Very simple yet advanced configuration. Minimal (one line) code configuration is required. It provides possibility to upload files, upload the content of a folder inclusively subfolders, enumerate buckets/container, enumerate the content of a specific 'subfolder', delete buckets/container and delete files from specific subfolders.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
8.0.0 86 1/1/2021
7.1.0 1,159 4/3/2020
7.0.0 10,952 8/4/2019
6.3.0 3,626 11/15/2018
6.2.0 450 10/10/2018
6.1.0 827 8/26/2018
6.0.0 455 7/22/2018
5.0.0 454 6/27/2018
4.0.0 528 6/2/2018
3.0.0 421 5/7/2018
2.0.0 478 4/25/2018
1.0.0 538 4/21/2018
Show less