file routes refactoring

This commit is contained in:
Peter Papp
2021-03-07 11:18:44 +01:00
parent 1f615c54af
commit 9f1174b547
5 changed files with 106 additions and 47 deletions

View File

@@ -102,21 +102,19 @@ class FileAccessController extends Controller
*/
public function get_zip($id)
{
$zip = Zip::where('id', $id)
$zip = Zip::whereId($id)
->where('user_id', Auth::id())
->first();
->firstOrFail();
$zip_path = 'zip/' . $zip->basename;
$disk = Storage::disk('local');
$header = [
return $disk->download("zip/$zip->basename", $zip->basename, [
"Content-Type" => 'application/zip',
"Content-Length" => Storage::disk('local')->size($zip_path),
"Content-Length" => $disk->size("zip/$zip->basename"),
"Accept-Ranges" => "bytes",
"Content-Range" => "bytes 0-600/" . Storage::disk('local')->size($zip_path),
"Content-Disposition" => "attachment; filename=" . $zip->basename,
];
return Storage::disk('local')->download($zip_path, $zip->basename, $header);
"Content-Range" => "bytes 0-600/" . $disk->size("zip/$zip->basename"),
"Content-Disposition" => "attachment; filename=$zip->basename",
]);
}
/**