Pericia.Storage.AzureBlobs
3.0.0-rc2
See the version list below for details.
dotnet add package Pericia.Storage.AzureBlobs --version 3.0.0-rc2
NuGet\Install-Package Pericia.Storage.AzureBlobs -Version 3.0.0-rc2
<PackageReference Include="Pericia.Storage.AzureBlobs" Version="3.0.0-rc2" />
paket add Pericia.Storage.AzureBlobs --version 3.0.0-rc2
#r "nuget: Pericia.Storage.AzureBlobs, 3.0.0-rc2"
// Install Pericia.Storage.AzureBlobs as a Cake Addin #addin nuget:?package=Pericia.Storage.AzureBlobs&version=3.0.0-rc2&prerelease // Install Pericia.Storage.AzureBlobs as a Cake Tool #tool nuget:?package=Pericia.Storage.AzureBlobs&version=3.0.0-rc2&prerelease
Pericia.Storage
Storage abstraction to store file in local file system or cloud storage.
Providers available for :
- File system
- OpenStack
- Azure Blobs
- AWS S3
- In-memory
How to use
The Pericia.Storage library provides an abstraction for cloud file storages. It is basically two interfaces :
IFileStorage
: represents a file storage services, which contains containers (identified by name)IFileStorageContainer
: represents a container in the service, where the files will be stored.
IFileStorage
contains the following method :
IFileStorageContainer GetContainer(string container);
: get a container for the current storage service.
IFileStorageContainer
contains the following methods :
Task<string> SaveFile(Stream fileData, string fileId)
: Save a file to the storage service, using its unique identifier. If a file with the same id exists, it is overwritten.Task<string> SaveFile(Stream fileData)
: save a file to the storage service, and returns the generated unique id of the file.Task<Stream> GetFile(string fileId)
: get the file content from the serviceTask DeleteFile(string fileId)
: delete the file from the service
Usage
You can use the service using one of the providers (see below for details on each provider). First thing to do is to add the Nuget package for your provider.
Direct usage
Each provider has a constructor with a single parameter containing the options (specific for each provider).
FileSystemStorageOptions options = new FileSystemStorageOptions() { Path = @"C:\files\" };
var fileService = new FileSystemStorage(options);
var container1 = fileService.GetContainer("container1");
Or you can directly use the container class :
var container2 = new FileSystemStorageContainer(options, "container2");
Usage with IoC
The packages contains helpers to register the services in you aspnet core IoC. First, use AddStorage to register the storage service, then add your provider, with its configuration :
public void ConfigureServices(IServiceCollection services)
{
var storageConfig = Configuration.GetSection("Storage");
services.AddStorage().AddFileSystem(storageConfig);
}
If you want to be able to switch provider in your configuration, you can set the provider name in the Provider
property of the options. Then you can add several providers, only the one in configuration will be registered :
services.AddStorage().AddFileSystem(storageConfig).AddAzureBlobs(storageConfig).AddOpenStack(storageConfig);
If you only want to use one container in your app, you can register it directly :
services.AddStorage().AddFileSystem(storageConfig).AddContainer("container1");
Providers
File System
This provider saves the files on the hard drive.
The only option needed is Path
, the directory path.
OpenStack
Saves to OpenStack. The following options are needed :
ApiEndpoint
: the openstack api urlAuthEndpoint
: the authentication urlTenantName
UserId
Password
AuthApiVersion
: set this value to2
if you want to use the v2 authentication API. If not set, the V3 API will be used.
Azure blobs
Saves the files to Azure Blob storage.
The only option needed is the ConnectionString
AWS S3
Saves the files to AWS S3 or any S3 compatible provider.
The options needed are the AccessKey
, SecretKey
, and either the RegionEndpoint
(for AWS) or ServiceUrl
(for S3-compatible providers)
In-memory
Store data in-memory - for testing purpose.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETCoreApp 3.1
- Azure.Storage.Blobs (>= 12.10.0)
- Pericia.Storage.Core (>= 3.0.0-rc2)
-
.NETStandard 2.0
- Azure.Storage.Blobs (>= 12.10.0)
- Pericia.Storage.Core (>= 3.0.0-rc2)
-
net5.0
- Azure.Storage.Blobs (>= 12.10.0)
- Pericia.Storage.Core (>= 3.0.0-rc2)
-
net6.0
- Azure.Storage.Blobs (>= 12.10.0)
- Pericia.Storage.Core (>= 3.0.0-rc2)
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 |
---|---|---|
4.1.1 | 84 | 9/27/2024 |
4.1.0 | 5,925 | 9/14/2023 |
4.0.0 | 496 | 11/8/2022 |
4.0.0-preview3 | 153 | 10/29/2022 |
4.0.0-preview2 | 145 | 10/4/2022 |
4.0.0-preview1 | 143 | 10/3/2022 |
3.0.0 | 450 | 1/20/2022 |
3.0.0-rc2 | 190 | 12/11/2021 |
3.0.0-rc1 | 223 | 12/8/2021 |