Is there a way to set the name of a download file to a value passed in as a query parameter?

I have a web API that gets and downloads a file when the end point is hit. Is there a way to set the download file name to a value that is passed into the web API as a query parameter?

We don't want to permanently rename the actual file itself, just the download file which the user gets when they hit the endpoint.#

Below is what I have so far.

Thanks for any help!

  Discussion posts and replies are publicly visible

Parents Reply Children
  • Hi, yes, it had occurred to me that a race-condition might be set up. As much as I'd like to be able to invoke a second process after the response had been sent by the WebAPI this isn't an option. Here's what you an do:

    • In the process once the copied document is created and control is returned to the WebAPI to return it in the body of the response you could add a wait timer set to, say, 60 seconds before the process moves on to delete the copy (Similarly, you could spawn a separate asynchronous instance whose job is to delete the target file and have that wait as the first thing it does)
    • In order to hand control back to the WebAPI you'll need to have the process chained up to but not including the timer
    • An alternate approach might be to store all of these cloned documents in a single folder and have an overnight process clear out that folder, if you can guarantee that other clones are being generated during this housekeeping process. If that's an issue then you could only delete documents that you find that are older than, say, 5 minutes form the time the process started.

    My go-to pattern is event-driven but I can't see how we can throw such an event in the WebAPI after the httpResponse() step which is the final step of a WebAPI.

  • Thanks Stewart, this almost works but for some reason my Web API is throwing a 500 error. 

    I don't see any errors in the process model - any idea what the issue might be here?