* Io module and content strategies * Restructuring the folders and projects * Create zip activity + shared content resolver * Fixing build on github.com * Update src/modules/Elsa.IO/Services/ContentResolver.cs explicit nullable field Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * QoL improvements * More QoL improvements + removing some logic duplications * Update src/modules/Elsa.IO.Compression/Activities/CreateZipArchive.cs avoiding duplicate extensions Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Assigning file path correctly to the variable * More QoL changes, new Elsa.IO.Http module, more modular content strategy * Addresing QoL review comments + Correct extension handling --------- Co-authored-by: lucas.hipolito <lukhipolito@yahoo.com.br> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
37 lines
1,008 B
C#
37 lines
1,008 B
C#
using Elsa.IO.Common;
|
|
using Elsa.IO.Extensions;
|
|
using Elsa.IO.Models;
|
|
|
|
namespace Elsa.IO.Services.Strategies;
|
|
|
|
/// <summary>
|
|
/// Strategy for handling Stream content.
|
|
/// </summary>
|
|
public class StreamContentStrategy : IContentResolverStrategy
|
|
{
|
|
/// <inheritdoc />
|
|
public float Priority => Constants.StrategyPriorities.Stream;
|
|
|
|
/// <inheritdoc />
|
|
public bool CanResolve(object content) => content is Stream;
|
|
|
|
/// <inheritdoc />
|
|
public Task<BinaryContent> ResolveAsync(object content, CancellationToken cancellationToken = default)
|
|
{
|
|
var stream = (Stream)content;
|
|
|
|
string? name = null;
|
|
if (stream is FileStream fileStream)
|
|
{
|
|
name = Path.GetFileName(fileStream.Name);
|
|
}
|
|
|
|
var result = new BinaryContent
|
|
{
|
|
Stream = stream,
|
|
Name = name?.GetNameAndExtension() ?? "data.bin",
|
|
};
|
|
|
|
return Task.FromResult(result);
|
|
}
|
|
} |