fix: 没有后缀名无法下载文件的问题

This commit is contained in:
kuaifan
2023-02-22 12:41:36 +08:00
parent ce7037d317
commit 9f7cdc34b4
4 changed files with 18 additions and 6 deletions

View File

@@ -11,6 +11,7 @@ use Illuminate\Support\Facades\Config;
use Overtrue\Pinyin\Pinyin;
use Redirect;
use Request;
use Response;
use Storage;
use Validator;
@@ -3182,4 +3183,17 @@ class Base
throw new ApiException($validator->errors()->first());
}
}
/**
* 流下载,解决没有后缀无法下载的问题
* @param $callback
* @param $name
* @return mixed
*/
public static function streamDownload($callback, $name = null) {
if ($name && !str_contains($name, '.')) {
$name .= ".";
}
return Response::streamDownload($callback, $name);
}
}