uuid.'/'.Str::uuid().'_'.$file->getClientOriginalName(); $disk->put($path, $file->get()); return SessionFile::create([ 'owner_ref' => $room->owner_ref, 'room_id' => $room->id, 'session_id' => $session?->id, 'uploaded_by_ref' => $uploadedByRef, 'uploaded_by_name' => $uploadedByName, 'original_name' => $file->getClientOriginalName(), 'storage_path' => $path, 'mime_type' => $file->getMimeType(), 'file_size' => $file->getSize(), 'expires_at' => $expiresInDays ? now()->addDays($expiresInDays) : null, ]); } public function linkFromDrive(Room $room, string $driveFileId, string $name, string $uploadedByRef, string $uploadedByName): SessionFile { return SessionFile::create([ 'owner_ref' => $room->owner_ref, 'room_id' => $room->id, 'uploaded_by_ref' => $uploadedByRef, 'uploaded_by_name' => $uploadedByName, 'original_name' => $name, 'storage_path' => '', 'drive_file_id' => $driveFileId, 'file_size' => 0, ]); } public function download(SessionFile $file, ?Participant $participant = null): string { abort_if($file->isExpired(), 410, 'File has expired.'); FileDownload::create([ 'session_file_id' => $file->id, 'downloaded_by_ref' => $participant?->user_ref, 'downloaded_by_name' => $participant?->display_name, 'ip_address' => request()?->ip(), 'downloaded_at' => now(), ]); if ($file->drive_file_id) { return $this->driveDownloadUrl($file->drive_file_id); } return Storage::disk(config('meet.files.disk', 'local'))->path($file->storage_path); } public function delete(SessionFile $file): void { if ($file->storage_path) { Storage::disk(config('meet.files.disk', 'local'))->delete($file->storage_path); } $file->delete(); } protected function driveDownloadUrl(string $driveFileId): string { $base = rtrim((string) config('meet.files.drive_api_url'), '/'); $key = config('meet.files.drive_api_key'); if ($base && $key) { try { $response = Http::withToken($key)->get("{$base}/files/{$driveFileId}/download-url"); if ($response->successful()) { return $response->json('url', $base.'/files/'.$driveFileId); } } catch (\Throwable) { // fall through } } return $base ? "{$base}/files/{$driveFileId}" : '#'; } }