From b151c0f50daf527decb154345d8cf076366e8eec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Mon, 25 May 2020 19:53:38 +0300 Subject: [PATCH] Created initial Volo.Abp.BlobStoring package --- framework/Volo.Abp.sln | 7 ++ .../src/Volo.Abp.BlobStoring/FodyWeavers.xml | 3 + .../src/Volo.Abp.BlobStoring/FodyWeavers.xsd | 30 +++++++ .../Volo.Abp.BlobStoring.csproj | 21 +++++ .../Abp/BlobStoring/AbpBlobStoringModule.cs | 9 ++ .../Volo/Abp/BlobStoring/IBlobManager.cs | 87 +++++++++++++++++++ 6 files changed, 157 insertions(+) create mode 100644 framework/src/Volo.Abp.BlobStoring/FodyWeavers.xml create mode 100644 framework/src/Volo.Abp.BlobStoring/FodyWeavers.xsd create mode 100644 framework/src/Volo.Abp.BlobStoring/Volo.Abp.BlobStoring.csproj create mode 100644 framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/AbpBlobStoringModule.cs create mode 100644 framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/IBlobManager.cs diff --git a/framework/Volo.Abp.sln b/framework/Volo.Abp.sln index 8e8dac2ce5..012ec976b6 100644 --- a/framework/Volo.Abp.sln +++ b/framework/Volo.Abp.sln @@ -291,6 +291,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.AspNetCore.SignalR EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Tests", "test\Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Tests\Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Tests.csproj", "{79323211-E658-493E-9863-035AA4C3F913}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.BlobStoring", "src\Volo.Abp.BlobStoring\Volo.Abp.BlobStoring.csproj", "{A0CFBDD6-A3CB-438C-83F1-5025F12E2D42}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -865,6 +867,10 @@ Global {79323211-E658-493E-9863-035AA4C3F913}.Debug|Any CPU.Build.0 = Debug|Any CPU {79323211-E658-493E-9863-035AA4C3F913}.Release|Any CPU.ActiveCfg = Release|Any CPU {79323211-E658-493E-9863-035AA4C3F913}.Release|Any CPU.Build.0 = Release|Any CPU + {A0CFBDD6-A3CB-438C-83F1-5025F12E2D42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A0CFBDD6-A3CB-438C-83F1-5025F12E2D42}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A0CFBDD6-A3CB-438C-83F1-5025F12E2D42}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A0CFBDD6-A3CB-438C-83F1-5025F12E2D42}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1012,6 +1018,7 @@ Global {B64FCE08-E9D2-4984-BF12-FE199F257416} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {8B758716-DCC9-4223-8421-5588D1597487} = {447C8A77-E5F0-4538-8687-7383196D04EA} {79323211-E658-493E-9863-035AA4C3F913} = {447C8A77-E5F0-4538-8687-7383196D04EA} + {A0CFBDD6-A3CB-438C-83F1-5025F12E2D42} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5} diff --git a/framework/src/Volo.Abp.BlobStoring/FodyWeavers.xml b/framework/src/Volo.Abp.BlobStoring/FodyWeavers.xml new file mode 100644 index 0000000000..be0de3a908 --- /dev/null +++ b/framework/src/Volo.Abp.BlobStoring/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/framework/src/Volo.Abp.BlobStoring/FodyWeavers.xsd b/framework/src/Volo.Abp.BlobStoring/FodyWeavers.xsd new file mode 100644 index 0000000000..3f3946e282 --- /dev/null +++ b/framework/src/Volo.Abp.BlobStoring/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/framework/src/Volo.Abp.BlobStoring/Volo.Abp.BlobStoring.csproj b/framework/src/Volo.Abp.BlobStoring/Volo.Abp.BlobStoring.csproj new file mode 100644 index 0000000000..cbf13cea87 --- /dev/null +++ b/framework/src/Volo.Abp.BlobStoring/Volo.Abp.BlobStoring.csproj @@ -0,0 +1,21 @@ + + + + + + + netstandard2.0 + Volo.Abp.BlobStoring + Volo.Abp.BlobStoring + $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; + false + false + false + + + + + + + + diff --git a/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/AbpBlobStoringModule.cs b/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/AbpBlobStoringModule.cs new file mode 100644 index 0000000000..d828c8434d --- /dev/null +++ b/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/AbpBlobStoringModule.cs @@ -0,0 +1,9 @@ +using Volo.Abp.Modularity; + +namespace Volo.Abp.BlobStoring +{ + public class AbpBlobStoringModule : AbpModule + { + + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/IBlobManager.cs b/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/IBlobManager.cs new file mode 100644 index 0000000000..26d3457cca --- /dev/null +++ b/framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/IBlobManager.cs @@ -0,0 +1,87 @@ +using System.IO; +using System.Threading; +using System.Threading.Tasks; + +namespace Volo.Abp.BlobStoring +{ + public interface IBlobContainer + { + /// + /// Saves a blob to the container. + /// + /// The name of the blob + /// A stream for the blob + /// + /// Set true to override if there is already a blob in the container with the given name. + /// If set to false (default), throws exception if there is already a blob in the container with the given name. + /// + /// Cancellation token + Task SaveAsync( + string name, + Stream stream, + bool overrideExisting = false, + CancellationToken cancellationToken = default + ); + + /// + /// Deletes a blob from the container. + /// + /// The name of the blob + /// Cancellation token + /// + /// Returns true if actually deleted the blob. + /// Returns false if the blob with the given was not exists. + /// + Task DeleteAsync( + string name, + CancellationToken cancellationToken = default + ); + + /// + /// Checks if a blob does exists in the container. + /// + /// The name of the blob + /// Cancellation token + Task ExistsAsync( + string name, + CancellationToken cancellationToken = default + ); + + /// + /// Gets a blob from the container. + /// It actually gets a to read the blob data. + /// It throws exception if there is no blob with the given . + /// Use if you want to get null if there is no blob with the given . + /// + /// The name of the blob + /// Cancellation token + /// + /// A to read the blob data. + /// + Task GetAsync( + string name, + CancellationToken cancellationToken = default + ); + + /// + /// Gets a blob from the container, or returns null if there is no blob with the given . + /// It actually gets a to read the blob data. + /// + /// The name of the blob + /// Cancellation token + /// + /// A to read the blob data. + /// + Task GetOrNullAsync( + string name, + CancellationToken cancellationToken = default + ); + + //TODO: Create shortcut extension methods: GetAsArraryAsync, GetAsStringAsync(encoding) (and null versions) + } + + public interface IBlobContainerManager + { + //Get (or create), Delete (if does exists) + } +} \ No newline at end of file