Download file programmatically
You can return a BinaryFileResponse from a controller, or as 4k4 has added:
$response = new BinaryFileResponse(&quot;public://cal/211443-event.ics&quot;);
$form_state-&gt;setResponse($response);