Skip to content

Commit c3a2af2

Browse files
committed
Add blob extension handling to BlobStorageWorkflowsProvider
- Introduce `BlobExtensions` for extracting blob file extensions. - Add `SupportsExtension` to `IBlobWorkflowFormatHandler` to filter handlers by supported extensions.
1 parent c048e65 commit c3a2af2

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using FluentStorage.Blobs;
2+
3+
namespace Elsa.Extensions;
4+
5+
public static class BlobExtensions
6+
{
7+
public static string GetExtension(this Blob blob) => Path.GetExtension(blob.Name).TrimStart('.');
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using Elsa.WorkflowProviders.BlobStorage.Contracts;
2+
3+
namespace Elsa.Extensions;
4+
5+
public static class BlobWorkflowFormatHandlerExtensions
6+
{
7+
public static bool SupportsExtension(this IBlobWorkflowFormatHandler handler, string extension) => handler.SupportedExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase);
8+
}

src/modules/Elsa.WorkflowProviders.BlobStorage/Providers/BlobStorageWorkflowsProvider.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Elsa.WorkflowProviders.BlobStorage.Contracts;
1+
using Elsa.Extensions;
2+
using Elsa.WorkflowProviders.BlobStorage.Contracts;
23
using Elsa.Workflows.Runtime;
34
using FluentStorage.Blobs;
45
using JetBrains.Annotations;
@@ -71,11 +72,13 @@ public async ValueTask<IEnumerable<MaterializedWorkflow>> GetWorkflowsAsync(Canc
7172
{
7273
var blobStorage = _blobStorageProvider.GetBlobStorage();
7374
var content = await blobStorage.ReadTextAsync(blob.FullPath, cancellationToken: cancellationToken);
74-
7575
var contentType = blob.Properties.TryGetValue("ContentType", out var ct) ? ct?.ToString() : null;
7676

7777
foreach (var handler in _handlers)
7878
{
79+
if (!handler.SupportsExtension(blob.GetExtension()))
80+
continue;
81+
7982
if (!handler.CanHandle(blob, contentType))
8083
continue;
8184

0 commit comments

Comments
 (0)