我需要将文件内容(如图像和其他mime类型)从Lumen资源服务器流式传输到Laravel客户端服务器。我知道在Laravel中我可以使用:
$headers = ['Content-Type' => 'image/png'];
$path = storage_path('/mnt/somestorage/example.png')
return response()->file($path, $headers);但是,Laravel\Lumen\Http\ResponseFactory中缺少file方法。
任何建议都非常受欢迎。
发布于 2018-01-24 20:00:18
在Lumen中,您可以使用Symfony的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;https://stackoverflow.com/questions/48402655
复制相似问题