I need to stream file content (such as images and other mime types) from a Lumen resource server to a Laravel client server. I know in Laravel I can use:
$headers = ['Content-Type' => 'image/png'];
$path = storage_path('/mnt/somestorage/example.png')
return response()->file($path, $headers);
However, the file
method is absent in Laravel\Lumen\Http\ResponseFactory
.
Any suggestions are very welcome.
Redirecting To Named RoutesWhen you call the redirect helper with no parameters, an instance of Laravel\Lumen\Http\Redirector is returned, allowing you to call any method on the Redirector instance.
To be precise, Lumen handles 100 requests per second. So, if speed is your requirement, then you know which framework to choose.
Differences between Laravel and Lumen: Laravel is an MVC based full-stack web application framework which supports a lot of third-party tools like Spatie, Entrust, Socialite etc and frameworks. Lumen is a micro framework, used to develop micro-services and API development in high speed and less time.
Lumen utilizes the Illuminate components that power the Laravel framework. As such, Lumen is built to painlessly upgrade directly to Laravel when needed; for example, when you discover that you need more features out of the box than what Lumen offers.
In Lumen you can use Symfony's BinaryFileResponse
.
use Symfony\Component\HttpFoundation\BinaryFileResponse
$type = 'image/png';
$headers = ['Content-Type' => $type];
$path = '/path/to/you/your/file.png';
$response = new BinaryFileResponse($path, 200 , $headers);
return $response;
You can find the documentation here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With