diff --git a/docs/en/Blob-Storing.md b/docs/en/Blob-Storing.md new file mode 100644 index 0000000000..d46f6e4cd5 --- /dev/null +++ b/docs/en/Blob-Storing.md @@ -0,0 +1,3 @@ +# Blog Storing + +TODO \ No newline at end of file diff --git a/docs/en/Blog-Posts/2020-06-05 v2_9_Release/Post.md b/docs/en/Blog-Posts/2020-06-05 v2_9_Release/Post.md index 858d61181b..90aa5771c7 100644 --- a/docs/en/Blog-Posts/2020-06-05 v2_9_Release/Post.md +++ b/docs/en/Blog-Posts/2020-06-05 v2_9_Release/Post.md @@ -14,4 +14,70 @@ You do nothing to get the benefit of the new system. [Overriding UI pages/compon ### New Blob Storing Package -We've \ No newline at end of file +We've created a new [Blob Storing package](https://www.nuget.org/packages/Volo.Abp.BlobStoring) to store arbitrary binary object. It is generally used to store files in your application. This package provides an abstraction, so any application or [module](https://docs.abp.io/en/abp/latest/Module-Development-Basics) can save and retrieve files independent from the actual storing provider. + +There are two storing provider currently implemented: + +* [Volo.Abp.BlobStoring.FileSystem](https://www.nuget.org/packages/Volo.Abp.BlobStoring.FileSystem) package stores objects/files in the local file system with a configured folder. +* [Volo.Abp.BlobStoring.Database](https://github.com/abpframework/abp/tree/dev/modules/blob-storing-database) module stores objects/files in a database. It currently supports [Entity Framework Core](https://docs.abp.io/en/abp/latest/Entity-Framework-Core) (so, you can use [any relational DBMS](https://docs.abp.io/en/abp/latest/Entity-Framework-Core-Other-DBMS)) and [MongoDB](https://docs.abp.io/en/abp/latest/MongoDB). + +[Azure BLOB provider](https://github.com/abpframework/abp/issues/4098) will be available with v3.0. You can request other cloud providers or contribute yourself on the [GitHub repository](https://github.com/abpframework/abp/issues/new). + +One of the benefit of the blob storing system it allows you to create multiple containers (each container is a blob storage) and use different storing providers for each container. + +**Example: Use the default container to save and get a byte array** + +````csharp +public class MyService : ITransientDependency +{ + private readonly IBlobContainer _container; + + public MyService(IBlobContainer container) + { + _container = container; + } + + public async Task FooAsync() + { + //Save a BLOB + byte[] bytes = GetBytesFromSomeWhere(); + await _container.SaveAsync("my-unique-blob-name", bytes); + + //Retrieve a BLOB + bytes = await _container.GetAllBytesAsync("my-unique-blob-name"); + } +} +```` + +It can work with `byte[]` and `Stream` objects. + +**Example: Use a typed (named) container to save and get a stream** + +````csharp +public class MyService : ITransientDependency +{ + private readonly IBlobContainer _container; + + public MyService(IBlobContainer container) + { + _container = container; + } + + public async Task FooAsync() + { + //Save a BLOB + Stream stream = GetStreamFromSomeWhere(); + await _container.SaveAsync("my-unique-blob-name", stream); + + //Retrieve a BLOB + stream = await _container.GetAsync("my-unique-blob-name"); + } +} +```` + +A typed (named) container can be configured to use a different storing provider than the default one. It is a good practice to always use a typed container while developing re-usable modules, so the final application can configure provider for this container without effecting the other containers. + + + +See the blob storing documentation for more information. +