带有 Lumen Api 的图像未在浏览器中显示

Image not show in browser with Lumen Api

我使用 Lumen 获取图像并在浏览器中显示,我在控制器中的代码是:

    use Illuminate\Support\Facades\File;

    $photo = $this->uploadFile->get_by_photo($photo, ['filename']);
    $path = storage_path('app') . '/' . $photo[0]['filename'];
    $file = File::get($path);
    $type = File::mimeType($path);
    $response = response()->make($file, 200);
    $response->header("Content-Type", $type);
    return $response;

但是图像没有在浏览器中显示,当 运行 api

时,我只是看到一个黑页

此代码有效:

    $photo = $this->uploadFile->get_by_photo($photo, ['filename']);
    $path = storage_path('app') . '/' . $photo[0]['filename'];
    $type = File::mimeType($path);
    $headers = array('Content-Type' => $type);
    $response = response()->download($path, $photo, $headers);
    ob_end_clean();
    return $response;