< Summary

Information
Class: Elsa.Http.DownloadableContentHandlers.FormFileDownloadableContentHandler
Assembly: Elsa.Http
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Http/DownloadableContentHandlers/FormFileDownloadableContentHandler.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 6
Coverable lines: 6
Total lines: 24
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
GetSupportsContent(...)100%210%
GetDownloadable(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Http/DownloadableContentHandlers/FormFileDownloadableContentHandler.cs

#LineLine coverage
 1using Elsa.Http.Abstractions;
 2using Elsa.Http.Contexts;
 3using Microsoft.AspNetCore.Http;
 4
 5namespace Elsa.Http.DownloadableContentHandlers;
 6
 7/// <summary>
 8/// Handles content that represents a downloadable stream.
 9/// </summary>
 10public class FormFileDownloadableContentHandler : DownloadableContentHandlerBase
 11{
 12    /// <inheritdoc />
 013    public override bool GetSupportsContent(object content) => content is IFormFile;
 14
 15    /// <inheritdoc />
 16    protected override Downloadable GetDownloadable(DownloadableContext context)
 17    {
 018        var file = (IFormFile)context.Content;
 019        var stream = file.OpenReadStream();
 020        var fileName = Path.GetFileName(file.FileName);
 021        var contentType = file.ContentType;
 022        return new Downloadable(stream, fileName, contentType);
 23    }
 24}