Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Warren Harding 132 posts 275 karma points
    Nov 29, 2023 @ 05:29
    Warren Harding

    workflow for file download

    Hi folks, I'm trying to get a workflow to download a file and not having much luck - has anyone had success with this and could help?

    Currently, I have a file attribute that allows the client to select a media item, I can open this and using SendFileAsync can see it start to download... but then when "return WorkflowExecutionStatus.Completed" gets called the request gets interupted and the file gets cancelled.

    Here's what I believe is the offending portion of code:

    var filepath = new FileInfo(filename);
    var response = _httpContextAccessor.HttpContext?.Response;
    response.Headers.Add("Content-Disposition", "attachment;filename=" + filepath.Name);
    response.Headers.Add("Content-Length", filepath.Length.ToString());
    response.Headers.Add("Content-Transfer-Encoding", "binary");
    new FileExtensionContentTypeProvider().Mappings.TryGetValue(filepath.Extension, out var contenttype);
    response.ContentType = contenttype ?? "application/octet-stream";
    return WorkflowExecutionStatus.Completed;

    Any help would be greatly appreciated, thank you.

  • Warren Harding 132 posts 275 karma points
    Nov 29, 2023 @ 05:29
    Warren Harding

    Sorry this should be in Ubmraco Forms category - I can't seem to move it.

  • Warren Harding 132 posts 275 karma points
    Dec 06, 2023 @ 22:01
    Warren Harding


  • Gilles 26 posts 108 karma points
    Apr 24, 2024 @ 15:27

    Hi, I'm trying to do a similar thing. Using your code I do get the very same result as you. Download is being interrupted.

    Did you happen you find a solution?


Please Sign in or register to post replies

Write your reply to: