diff --git a/src/activities/Elsa.Activities.AzureServiceBus/Elsa.Activities.AzureServiceBus.csproj b/src/activities/Elsa.Activities.AzureServiceBus/Elsa.Activities.AzureServiceBus.csproj
index 3355d3020..7c7e36e90 100644
--- a/src/activities/Elsa.Activities.AzureServiceBus/Elsa.Activities.AzureServiceBus.csproj
+++ b/src/activities/Elsa.Activities.AzureServiceBus/Elsa.Activities.AzureServiceBus.csproj
@@ -1,22 +1,22 @@
-
-
-
+
+
+
netstandard2.1
Elsa is a set of workflow libraries and tools that enable lean and mean workflowing capabilities in any .NET Core application.
This package provides activities to send and receive messages using Azure Service Bus.
-
+
elsa, workflows
-
+
-
+
diff --git a/src/activities/Elsa.Activities.BlobStorage/Activities/BlobExists.cs b/src/activities/Elsa.Activities.BlobStorage/Activities/BlobExists.cs
index d334e8864..c91d83e3d 100644
--- a/src/activities/Elsa.Activities.BlobStorage/Activities/BlobExists.cs
+++ b/src/activities/Elsa.Activities.BlobStorage/Activities/BlobExists.cs
@@ -1,10 +1,8 @@
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.IO;
-using System.Linq;
+using System;
using System.Threading.Tasks;
using Elsa.ActivityResults;
using Elsa.Attributes;
+using Elsa.Expressions;
using Elsa.Services;
using Elsa.Services.Models;
using Storage.Net.Blobs;
@@ -14,27 +12,26 @@ namespace Elsa.Activities.BlobStorage
{
[Action(
Category = "BlobStorage",
+ Description = "Check if a blob exists on the storage engine.",
Outcomes = new[] { OutcomeNames.True, OutcomeNames.False }
)]
public class BlobExists : Activity
{
- public BlobExists(IBlobStorage storage)
- {
- _storage = storage;
- }
private readonly IBlobStorage _storage;
+ public BlobExists(IBlobStorage storage) => _storage = storage;
- [ActivityProperty(Hint = "The Id of the blob")]
- public string BlobId { get; set; }
+ [ActivityProperty(Hint = "The ID of the blob.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })]
+ public string BlobId { get; set; } = default!;
protected override async ValueTask OnExecuteAsync(ActivityExecutionContext context)
{
if (string.IsNullOrWhiteSpace(BlobId))
- throw new System.Exception($"BlobId must have a value");
+ throw new Exception($"{nameof(BlobId)} must have a value");
+
if (await _storage.ExistsAsync(BlobId))
return Outcome(OutcomeNames.True);
- else
- return Outcome(OutcomeNames.False);
+
+ return Outcome(OutcomeNames.False);
}
}
}
\ No newline at end of file
diff --git a/src/activities/Elsa.Activities.BlobStorage/Activities/DeleteBlob.cs b/src/activities/Elsa.Activities.BlobStorage/Activities/DeleteBlob.cs
index 62f723bb2..eb26ed737 100644
--- a/src/activities/Elsa.Activities.BlobStorage/Activities/DeleteBlob.cs
+++ b/src/activities/Elsa.Activities.BlobStorage/Activities/DeleteBlob.cs
@@ -1,6 +1,4 @@
using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Elsa.ActivityResults;
@@ -15,27 +13,27 @@ using Storage.Net.Blobs;
namespace Elsa.Activities.BlobStorage
{
[Action(
- Category = "BlobStorage",
+ Category = "BlobStorage",
+ Description = "Delete a blob from the storage engine.",
Outcomes = new[] { OutcomeNames.Done }
)]
public class DeleteBlob : Activity
{
- public DeleteBlob(IBlobStorage storage)
- {
- _storage = storage;
- }
private readonly IBlobStorage _storage;
+ public DeleteBlob(IBlobStorage storage) => _storage = storage;
- [ActivityProperty(Hint = "The Ids of the blobs",
- UIHint = ActivityPropertyUIHints.MultiText,
+ [ActivityProperty(
+ Hint = "The IDs of the blobs.",
+ UIHint = ActivityPropertyUIHints.MultiText,
DefaultSyntax = SyntaxNames.Json,
- SupportedSyntaxes = new[] { SyntaxNames.Json, SyntaxNames.JavaScript, SyntaxNames.Liquid })]
+ SupportedSyntaxes = new[] { SyntaxNames.Json, SyntaxNames.JavaScript, SyntaxNames.Liquid }
+ )]
public IList BlobIds { get; set; } = new List();
protected override async ValueTask OnExecuteAsync(ActivityExecutionContext context)
{
- if (BlobIds==default || !BlobIds.Any())
- throw new System.Exception($"BlobID or BlobIds must have a value");
+ if (BlobIds == default || !BlobIds.Any())
+ throw new System.Exception($"BlobID or BlobIds must have a value");
await _storage.DeleteAsync(BlobIds, context.CancellationToken);
return Done();
}
diff --git a/src/activities/Elsa.Activities.BlobStorage/Activities/ReadBlob.cs b/src/activities/Elsa.Activities.BlobStorage/Activities/ReadBlob.cs
index 97ffddd7b..a1805906a 100644
--- a/src/activities/Elsa.Activities.BlobStorage/Activities/ReadBlob.cs
+++ b/src/activities/Elsa.Activities.BlobStorage/Activities/ReadBlob.cs
@@ -1,6 +1,4 @@
using System.ComponentModel.DataAnnotations;
-using System.IO;
-using System.Linq;
using System.Threading.Tasks;
using Elsa.ActivityResults;
using Elsa.Attributes;
@@ -13,34 +11,30 @@ namespace Elsa.Activities.BlobStorage
{
[Action(
Category = "BlobStorage",
- Description = "Reads a blob from the storage engine",
+ Description = "Reads a blob from the storage engine.",
Outcomes = new[] { OutcomeNames.Done }
)]
public class ReadBlob : Activity
{
- public ReadBlob(IBlobStorage storage)
- {
- _storage = storage;
- }
private readonly IBlobStorage _storage;
+ public ReadBlob(IBlobStorage storage) => _storage = storage;
[ActivityProperty(Hint = "The Id assigned to the blob.")]
[Required]
- public string BlobId { get; set; }
+ public string BlobId { get; set; } = default!;
- [ActivityProperty(Hint = "If set, the output of this activity is written into the specified file, alternatively the outcome contains the bytes of the blob")]
- public string FilePath { get; set; }
+ [ActivityProperty(Hint = "If set, the output of this activity is written to the specified file. Otherwise, the bytes of the blob will be set as the activity output.")]
+ public string? DestinationFilePath { get; set; }
protected override async ValueTask OnExecuteAsync(ActivityExecutionContext context)
{
if (string.IsNullOrWhiteSpace(BlobId))
- throw new System.Exception($"BlobId must have a value");
- if (!string.IsNullOrWhiteSpace(FilePath))
- await _storage.ReadToFileAsync(BlobId, FilePath, context.CancellationToken);
- else
- {
- Done(await _storage.ReadBytesAsync(BlobId, context.CancellationToken));
- }
+ throw new System.Exception($"{nameof(BlobId)} must have a value");
+
+ if (string.IsNullOrWhiteSpace(DestinationFilePath))
+ return Done(await _storage.ReadBytesAsync(BlobId, context.CancellationToken));
+
+ await _storage.ReadToFileAsync(BlobId, DestinationFilePath, context.CancellationToken);
return Done();
}
}
diff --git a/src/activities/Elsa.Activities.BlobStorage/Activities/WriteBlob.cs b/src/activities/Elsa.Activities.BlobStorage/Activities/WriteBlob.cs
index 181f93adf..4e1cf39a4 100644
--- a/src/activities/Elsa.Activities.BlobStorage/Activities/WriteBlob.cs
+++ b/src/activities/Elsa.Activities.BlobStorage/Activities/WriteBlob.cs
@@ -4,6 +4,7 @@ using System.Linq;
using System.Threading.Tasks;
using Elsa.ActivityResults;
using Elsa.Attributes;
+using Elsa.Expressions;
using Elsa.Services;
using Elsa.Services.Models;
using Storage.Net.Blobs;
@@ -13,7 +14,7 @@ namespace Elsa.Activities.BlobStorage
{
[Action(
Category = "BlobStorage",
- Description = "Write a blob to the storage engine",
+ Description = "Write a blob to the storage engine.",
Outcomes = new[] { OutcomeNames.Done }
)]
public class WriteBlob : Activity
@@ -22,26 +23,24 @@ namespace Elsa.Activities.BlobStorage
{
_storage = storage;
}
+
private readonly IBlobStorage _storage;
- [ActivityProperty(Hint = "The ID to be assigned to the blob. It's needed to retrieve the blob")]
+ [ActivityProperty(Hint = "The ID to be assigned to the blob.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript, SyntaxNames.Liquid })]
[Required]
- public string BlobID { get; set; }
+ public string BlobId { get; set; } = default!;
- [ActivityProperty(Hint = "The bytes")]
- public byte[] Bytes { get; set; }
-
- [ActivityProperty(Hint = "The file path")]
- public string FilePath { get; set; }
+ [ActivityProperty(Hint = "The bytes to write.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript }, DefaultSyntax = SyntaxNames.JavaScript)]
+ public byte[]? Bytes { get; set; }
protected override async ValueTask OnExecuteAsync(ActivityExecutionContext context)
{
- if (string.IsNullOrWhiteSpace(BlobID))
- throw new System.Exception($"BlobID must have a value");
- if (!string.IsNullOrWhiteSpace(FilePath))
- await _storage.WriteFileAsync(BlobID, FilePath, context.CancellationToken);
- if(Bytes!=default && Bytes.Any())
- await _storage.WriteAsync(BlobID, new MemoryStream(Bytes), default, context.CancellationToken);
+ if (string.IsNullOrWhiteSpace(BlobId))
+ throw new System.Exception($"{nameof(BlobId)} must have a value");
+
+ if (Bytes != default && Bytes.Any())
+ await _storage.WriteAsync(BlobId, new MemoryStream(Bytes), default, context.CancellationToken);
+
return Done();
}
}
diff --git a/src/activities/Elsa.Activities.BlobStorage/Elsa.Activities.BlobStorage.csproj b/src/activities/Elsa.Activities.BlobStorage/Elsa.Activities.BlobStorage.csproj
index 102c2fca5..d709fab3c 100644
--- a/src/activities/Elsa.Activities.BlobStorage/Elsa.Activities.BlobStorage.csproj
+++ b/src/activities/Elsa.Activities.BlobStorage/Elsa.Activities.BlobStorage.csproj
@@ -1,16 +1,24 @@
-
- netstandard2.1
- Luca Pisano
-
+
+
-
-
-
+
+ netstandard2.1
+ Luca Pisano, Elsa Contributors
+
+ Elsa is a set of workflow libraries and tools that enable lean and mean workflowing capabilities in any .NET Core application.
+ This package provides activities to read and write files to blob storage using Storage.Net that provides a generic interface for popular cloud storage providers like Amazon S3, Azure Service Bus, Azure Event Hub, Azure Storage, Azure Data Lake Store thus abstracting Blob and Messaging services.
+
+ elsa, workflows, blob storage
+
-
-
-
+
+
+
+
+
+
+
diff --git a/src/activities/Elsa.Activities.BlobStorage/Extensions/ServiceCollectionExtensions.cs b/src/activities/Elsa.Activities.BlobStorage/Extensions/ServiceCollectionExtensions.cs
index 34a83eb37..55b16840d 100644
--- a/src/activities/Elsa.Activities.BlobStorage/Extensions/ServiceCollectionExtensions.cs
+++ b/src/activities/Elsa.Activities.BlobStorage/Extensions/ServiceCollectionExtensions.cs
@@ -1,6 +1,4 @@
using System;
-using System.IO;
-using System.Linq;
using Elsa;
using Elsa.Activities.BlobStorage;
using Storage.Net.Blobs;
@@ -10,10 +8,11 @@ namespace Microsoft.Extensions.DependencyInjection
{
public static class ServiceCollectionExtensions
{
- public static ElsaOptions AddBlobStorageActivities(this ElsaOptions options, Func implementation=default)
+ public static ElsaOptionsBuilder AddBlobStorageActivities(this ElsaOptionsBuilder options, Func? configureBlobStorage = default)
{
- if (implementation != default)
- options.UseStorage(implementation);
+ if (configureBlobStorage != default)
+ options.UseStorage(configureBlobStorage);
+
options
.AddActivity()
.AddActivity()