stream($request, $id, $image, 'original'); } public function published(Request $request, int $id, int $image): StreamedResponse|View { return $this->stream($request, $id, $image, 'published'); } private function stream(Request $request, int $pressReleaseId, int $imageId, string $kind): StreamedResponse|View { $pressRelease = PressRelease::withoutGlobalScope(PortalScope::class)->findOrFail($pressReleaseId); $image = PressReleaseImage::query()->withTrashed()->where('press_release_id', $pressRelease->getKey())->findOrFail($imageId); if ($image->trashed()) { Gate::authorize(Permission::ComplianceManage); } $purpose = $request->isMethod('post') ? trim((string) $request->request->get('purpose', '')) : ''; if ($purpose === '') { abort_if($request->isMethod('post'), 422, 'Zweck des Zugriffs fehlt (purpose).'); return view('admin.archive.purpose', [ 'formAction' => route($kind === 'original' ? 'admin.press-releases.images.original' : 'admin.press-releases.images.published', ['id' => $pressRelease->getKey(), 'image' => $image->getKey()]), 'description' => __(':kind zu Bild #:image (PM #:pr). Jeder Abruf wird mit Zweck protokolliert.', [ 'kind' => $kind === 'original' ? __('Beweisoriginal') : __('Veröffentlichte Fassung'), 'image' => $image->getKey(), 'pr' => $pressRelease->getKey(), ]), 'submitLabel' => __('Datei öffnen'), 'cancelUrl' => route('admin.press-releases.show', ['id' => $pressRelease->getKey()]), ]); } $path = $kind === 'original' ? $image->original_path : $image->published_snapshot_path; $disk = Storage::disk($image->original_disk ?? (string) config('images.originals_disk')); abort_unless(is_string($path) && $path !== '' && $disk->exists($path), 404); $this->activityLog->record( ActivityType::EvidenceAccess, sprintf('%s zu Bild #%d (PM #%d) abgerufen: %s', $kind === 'original' ? 'Beweisoriginal' : 'Veröffentlichte Fassung', $image->getKey(), $pressRelease->getKey(), $purpose), $request->user(), $image, ['kind' => $kind, 'purpose' => $purpose, 'sha256' => $kind === 'original' ? $image->original_sha256 : $image->published_snapshot_sha256], ); return $disk->response($path, basename($path), [ 'Cache-Control' => 'private, no-store', 'X-Content-Type-Options' => 'nosniff', ]); } }