A worker to stream just-in-time a HTTP Response from a iterator
-
Add the module in your project
composer require "photon/worker-download"
-
Add the worker in the configuration
'installed_tasks' => array( 'PhotonDownload' => '\photon\task\PhotonDownload', ), 'photon_task_PhotonDownload' => array( 'sub_addr' => 'tcp://127.0.0.1:11011', ),
-
Start the worker
hnu worker PhotonDownload
-
Send work to the worker in a view
public function m2stream($request, $match) { $ans = new \photon\http\Response(new MyStream); $ans->headers['Content-Length'] = 247463936;
\photon\task\PhotonDownload::createDownload($request, $ans); return false;
}