fix: 下载文件出现文件损坏的情况

This commit is contained in:
kuaifan
2022-12-18 16:02:57 +08:00
parent e18fcd5c43
commit f0d0ee69c8
5 changed files with 24 additions and 10 deletions

View File

@@ -17,6 +17,7 @@ use Hhxsv5\LaravelS\Swoole\Task\Task;
use LasseRafn\InitialAvatarGenerator\InitialAvatar;
use Redirect;
use Request;
use Response;
/**
@@ -269,7 +270,7 @@ class IndexController extends InvokeController
if (preg_match("/^\d+\.\d+\.\d+$/", $genericVersion)) {
$filePath = public_path("uploads/desktop/{$genericVersion}/{$name}");
if (file_exists($filePath)) {
return response()->download($filePath);
return Response::download($filePath);
}
}
}
@@ -317,7 +318,7 @@ class IndexController extends InvokeController
$userAgent = strtolower(Request::server('HTTP_USER_AGENT'));
if ($ext === 'pdf'
&& (str_contains($userAgent, 'electron') || str_contains($userAgent, 'chrome'))) {
return response()->download($file, $name, [
return Response::download($file, $name, [
'Content-Type' => 'application/pdf'
], 'inline');
}