fix: 没有后缀名无法下载文件的问题
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user