我试图用laravel下载文件,但一直收到未找到的消息。我尝试了很多东西,而我做的最后一件事是:
public function download($id)
{
$allowed_guards = ['managers', 'staff'];
if (!$this->autherize($allowed_guards))
{
response()->json(['error' => 401], 200);
}
$this->user = Auth::guard($this->guard)->user();
$asset = FileForAssignment::find($id);
$assetPath = Storage::disk('s3')->url($asset->path);
return response()->download(storage_path($assetPath));
}