mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-nostr.git
synced 2026-01-28 07:43:18 +00:00
🔒 Update media routes to support private disk and enhance file handling
- 🗂️ Change default filesystem disk from `local` to `private` in configuration - 📤 Use `Storage::disk` for media download and response functionality - ⚙️ Refactor download and file response logic for improved security and consistency
This commit is contained in:
@@ -3,21 +3,29 @@
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
|
||||
Route::redirect('/', '/association/profile');
|
||||
|
||||
Route::get('dl/{media}', function (Media $media, Request $request) {
|
||||
return response()->download($media->getPath(), $media->name);
|
||||
return Storage::disk($media->disk)->download(
|
||||
$media->getPathRelativeToRoot(),
|
||||
$media->file_name
|
||||
);
|
||||
})
|
||||
->name('dl')
|
||||
->middleware('signed');
|
||||
|
||||
Route::get('media/{media}', function (Media $media, Request $request) {
|
||||
return response()->file($media->getPath(), [
|
||||
'Content-Type' => $media->mime_type,
|
||||
'Cache-Control' => 'private, max-age=3600',
|
||||
]);
|
||||
return Storage::disk($media->disk)->response(
|
||||
$media->getPathRelativeToRoot(),
|
||||
$media->file_name,
|
||||
[
|
||||
'Content-Type' => $media->mime_type,
|
||||
'Cache-Control' => 'private, max-age=3600',
|
||||
]
|
||||
);
|
||||
})
|
||||
->name('media.signed')
|
||||
->middleware('signed');
|
||||
|
||||
Reference in New Issue
Block a user