I'm trying to trigger an event when a download completes. Currently, my Controller just returns the Response, but as far as I can tell there's not way for me to know when the download has actually completed.
Asked
Active
Viewed 88 times
0
-
I take it that the [kernel.terminate event](https://symfony.com/doc/current/reference/events.html#kernel-terminate) does not do what you want? Have not tried it myself. – Cerad Aug 01 '18 at 20:07
-
You might want to check [`StreamedResponse`](https://symfony.com/doc/current/components/http_foundation.html#streaming-a-response) to know when last chunk is sent out, but that is still not reliable because, as far as client is concerned, the socket may be even closed. What @Cerad suggested may be the closest.. – Jovan Perovic Aug 02 '18 at 10:08
-
That actually might be what I need. I'll give it a shot. Thanks! – robert.bo.roth Aug 02 '18 at 14:12
-
If I read correctly, you want to trigger an event when the client downloaded the last bit of a file, right ? So unless you send the file with PHP in chunks or have the page designed somehow to give back a signal when download is complete, I don't see any way to solve this with Kernel events. I mean, you as a client can stop the download, or anything alike, in this case you are not connected to symfony. Are you just returning a download link from Symfony or how are you doing this ? – Martin Fasani Aug 07 '18 at 08:00
-
And sorry but this question is missing information, at least could provide a clear code example of what you are trying to do if you expect any help – Martin Fasani Aug 10 '18 at 07:25