JoewyZN's avatar

Download File using an event

Hi ! I am trying to download a file using an event...

I am using the following facade

use Illuminate\Support\Facades\Response;

and my method call looks like

Response::download($path)->deleteFileAfterSend(true);

This works normally via the controller but doesn't seem to work via the event.. any help ?

0 likes
3 replies
bashy's avatar
bashy
Best Answer
Level 65

Since an event is in the background, it won't have a client? No browser to read the headers and download the file.

JoewyZN's avatar

I figured, Thanks @bash .. although it doesn't make sense, a request is a request, whether you're calling it in the background or not.. Anyways I will figure something out..

bashy's avatar

@JoewyZN Well, it is, but events are fired from the console (queue) not a web request. I would email a link or have a socket to push the link to the user. You can also do it on refresh maybe. Redirect to a page then keep refreshing until link is ready?

1 like

Please or to participate in this conversation.