elsa-core/src/modules/Elsa.Http/DownloadableContentHandlers/BinaryDownloadableContentHandler.cs
Sipke Schoorstra 225a99f39d
Bulk Import + Export of Workflow Definitions and Instances (#4643)
* Implement bulk export of workflow definitions

* Update Import endpoint with support for file uploads

* Update Import endpoint to return imported workflow count

* Implement workflow instance (bulk) export

* Implement workflow state, bookmark, workflow + activity execution export

* Remove globally imported usings
2023-11-22 14:31:48 +01:00

24 lines
760 B
C#

using Elsa.Http.Abstractions;
using Elsa.Http.Contexts;
using Elsa.Http.Models;
namespace Elsa.Http.DownloadableContentHandlers;
/// <summary>
/// Handles content that represents a downloadable binary file.
/// </summary>
public class BinaryDownloadableContentHandler : DownloadableContentHandlerBase
{
/// <inheritdoc />
public override bool GetSupportsContent(object content) => content is byte[];
/// <inheritdoc />
protected override Downloadable GetDownloadable(DownloadableContext context)
{
var bytes = (byte[]) context.Content;
var stream = new MemoryStream(bytes);
var fileName = "file.bin";
var contentType = "application/octet-stream";
return new(stream, fileName, contentType);
}
}