addressed revision suggestions
This commit is contained in:
parent
2205b91e9e
commit
d0a48d5fb4
|
|
@ -24,14 +24,14 @@ namespace Elsa.Activities.BlobStorage
|
|||
}
|
||||
private readonly IBlobStorage _storage;
|
||||
|
||||
[ActivityProperty(Hint = "The ID of the blob")]
|
||||
public string BlobID { get; set; }
|
||||
[ActivityProperty(Hint = "The Id of the blob")]
|
||||
public string BlobId { get; set; }
|
||||
|
||||
protected override async ValueTask<IActivityExecutionResult> OnExecuteAsync(ActivityExecutionContext context)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(BlobID))
|
||||
throw new System.Exception($"BlobID must have a value");
|
||||
if (await _storage.ExistsAsync(BlobID))
|
||||
if (string.IsNullOrWhiteSpace(BlobId))
|
||||
throw new System.Exception($"BlobId must have a value");
|
||||
if (await _storage.ExistsAsync(BlobId))
|
||||
return Outcome(OutcomeNames.True);
|
||||
else
|
||||
return Outcome(OutcomeNames.False);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ using System.Linq;
|
|||
using System.Threading.Tasks;
|
||||
using Elsa.ActivityResults;
|
||||
using Elsa.Attributes;
|
||||
using Elsa.Design;
|
||||
using Elsa.Expressions;
|
||||
using Elsa.Services;
|
||||
using Elsa.Services.Models;
|
||||
using Storage.Net.Blobs;
|
||||
|
|
@ -24,18 +26,17 @@ namespace Elsa.Activities.BlobStorage
|
|||
}
|
||||
private readonly IBlobStorage _storage;
|
||||
|
||||
[ActivityProperty(Hint = "The ID of the blob")]
|
||||
public string BlobID { get; set; }
|
||||
[ActivityProperty(Hint = "The IDs of the blob")]
|
||||
public List<string> BlobIDs { get; set; } = new List<string>();
|
||||
[ActivityProperty(Hint = "The Ids of the blobs",
|
||||
UIHint = ActivityPropertyUIHints.MultiText,
|
||||
DefaultSyntax = SyntaxNames.Json,
|
||||
SupportedSyntaxes = new[] { SyntaxNames.Json, SyntaxNames.JavaScript, SyntaxNames.Liquid })]
|
||||
public IList<string> BlobIds { get; set; } = new List<string>();
|
||||
|
||||
protected override async ValueTask<IActivityExecutionResult> OnExecuteAsync(ActivityExecutionContext context)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(BlobID) && (BlobIDs==default || !BlobIDs.Any()))
|
||||
throw new System.Exception($"BlobID or BlobIds must have a value");
|
||||
if (BlobID != default)
|
||||
BlobIDs.Add(BlobID);
|
||||
await _storage.DeleteAsync(BlobIDs);
|
||||
if (BlobIds==default || !BlobIds.Any())
|
||||
throw new System.Exception($"BlobID or BlobIds must have a value");
|
||||
await _storage.DeleteAsync(BlobIds);
|
||||
return Done();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,22 +24,23 @@ namespace Elsa.Activities.BlobStorage
|
|||
}
|
||||
private readonly IBlobStorage _storage;
|
||||
|
||||
[ActivityProperty(Hint = "The ID assigned to the blob.")]
|
||||
[ActivityProperty(Hint = "The Id assigned to the blob.")]
|
||||
[Required]
|
||||
public string BlobID { get; set; }
|
||||
[ActivityProperty(Hint = "The bytes")]
|
||||
public byte[] Bytes { get; set; }
|
||||
[ActivityProperty(Hint = "The output file path, alternative to Bytes")]
|
||||
public string BlobId { get; set; }
|
||||
|
||||
[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; }
|
||||
|
||||
protected override async ValueTask<IActivityExecutionResult> OnExecuteAsync(ActivityExecutionContext context)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(BlobID))
|
||||
throw new System.Exception($"BlobID must have a value");
|
||||
if (string.IsNullOrWhiteSpace(BlobId))
|
||||
throw new System.Exception($"BlobId must have a value");
|
||||
if (!string.IsNullOrWhiteSpace(FilePath))
|
||||
await _storage.ReadToFileAsync(BlobID, FilePath, context.CancellationToken);
|
||||
await _storage.ReadToFileAsync(BlobId, FilePath, context.CancellationToken);
|
||||
else
|
||||
Bytes = await _storage.ReadBytesAsync(BlobID);
|
||||
{
|
||||
Done(await _storage.ReadBytesAsync(BlobId));
|
||||
}
|
||||
return Done();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,10 @@ namespace Elsa.Activities.BlobStorage
|
|||
[ActivityProperty(Hint = "The ID to be assigned to the blob. It's needed to retrieve the blob")]
|
||||
[Required]
|
||||
public string BlobID { get; set; }
|
||||
|
||||
[ActivityProperty(Hint = "The bytes")]
|
||||
public byte[] Bytes { get; set; }
|
||||
|
||||
[ActivityProperty(Hint = "The file path")]
|
||||
public string FilePath { get; set; }
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue