Browse Source

Complete BLOB Storing: Creating a Custom Provider.

pull/4305/head
Halil İbrahim Kalkan 6 years ago
parent
commit
1c735a84f4
  1. 87
      docs/en/Blob-Storing-Custom-Provider.md
  2. 2
      docs/en/Blob-Storing-File-System.md
  3. 4
      docs/en/Blob-Storing.md

87
docs/en/Blob-Storing-Custom-Provider.md

@ -1,3 +1,88 @@
# BLOB Storing: Creating a Custom Provider
TODO
This document explains how you can create a new storage provider for the BLOB storing system with an example.
> Read the [BLOB Storing document](Blob-Storing.md) to understand how to use the BLOB storing system. This document only covers how to create a new storage provider.
## Example Implementation
The first step is to create a class implements the `IBlobProvider` interface or inherit from the `BlobProviderBase` abstract class.
````csharp
using System.IO;
using System.Threading.Tasks;
using Volo.Abp.BlobStoring;
using Volo.Abp.DependencyInjection;
namespace AbpDemo
{
public class MyCustomBlobProvider : BlobProviderBase, ITransientDependency
{
public override Task SaveAsync(BlobProviderSaveArgs args)
{
//TODO...
}
public override Task<bool> DeleteAsync(BlobProviderDeleteArgs args)
{
//TODO...
}
public override Task<bool> ExistsAsync(BlobProviderExistsArgs args)
{
//TODO...
}
public override Task<Stream> GetOrNullAsync(BlobProviderGetArgs args)
{
//TODO...
}
}
}
````
* `MyCustomBlobProvider` inherits from the `BlobProviderBase` and overrides the `abstract` methods. The actual implementation is up to you.
* Implementing `ITransientDependency` registers this class to the [Dependency Injection](Dependency-Injection.md) system as a transient service.
That's all. Now, you can configure containers (inside the `ConfigureServices` method of your [module](Module-Development-Basics.md)) to use the `MyCustomBlobProvider` class:
````csharp
Configure<AbpBlobStoringOptions>(options =>
{
options.Containers.ConfigureDefault(container =>
{
container.ProviderType = typeof(MyCustomBlobProvider);
});
});
````
> See the [BLOB Storing document](Blob-Storing.md) if you want to configure a specific container.
### BlobContainerConfiguration Extension Method
If you want to provide a simpler configuration, create an extension method for the `BlobContainerConfiguration` class:
````
public static class MyBlobContainerConfigurationExtensions
{
public static BlobContainerConfiguration UseMyCustomBlobProvider(
this BlobContainerConfiguration containerConfiguration)
{
containerConfiguration.ProviderType = typeof(MyCustomBlobProvider);
return containerConfiguration;
}
}
````
Then you can configure containers easier using the extension method:
````csharp
Configure<AbpBlobStoringOptions>(options =>
{
options.Containers.ConfigureDefault(container =>
{
container.UseMyCustomBlobProvider();
});
});
````

2
docs/en/Blob-Storing-File-System.md

@ -2,7 +2,7 @@
File System Storage Provider is used to store BLOBs in the local file system as standard files inside a folder.
> Read the BLOB Storing document to understand how to use the BLOB storing system. This document only covers how to configure containers to use the file system.
> Read the [BLOB Storing document](Blob-Storing.md) to understand how to use the BLOB storing system. This document only covers how to configure containers to use the file system.
## Installation

4
docs/en/Blob-Storing.md

@ -20,9 +20,9 @@ ABP Framework has the following storage provider implementations;
* [Database](Blob-Storing-Database.md): Stores BLOBs in a database.
* [Azure](Blob-Storing-Azure.md): Stores BLOBs on the [Azure BLOB storage](https://azure.microsoft.com/en-us/services/storage/blobs/).
More providers will be implemented by the time. You can [request](https://github.com/abpframework/abp/issues/new) it for your favorite provider or [create it yourself](Blob-Storing-Custom-Provider.md).
More providers will be implemented by the time. You can [request](https://github.com/abpframework/abp/issues/new) it for your favorite provider or [create it yourself](Blob-Storing-Custom-Provider.md) and [contribute](Contribution/Index.md) to the ABP Framework.
Multiple providers **can be used together** by the help of the **container system**, where each container can use a different provider (will be explained below).
Multiple providers **can be used together** by the help of the **container system**, where each container can uses a different provider.
> BLOB storing system can not work unless you **configure a storage provider**. Refer to the linked documents for the storage provider configurations.

Loading…
Cancel
Save