route()->parameter('bundle')), 401); abort_if(empty($request->auth), 401); // Getting metadata $metadata = Upload::getMetadata($request->route()->parameter('bundle')); // Aborting if metadata are empty abort_if(empty($metadata), 404); // Aborting if auth_token is different from URL param abort_if($metadata['preview_token'] !== $request->auth, 401); // Checking bundle expiration abort_if($metadata['expires_at'] < time(), 404); // If there is no file into the bundle (should never happen but ...) abort_if(count($metadata['files']) == 0, 404); abort_if(($metadata['max_downloads'] ?? 0) > 0 && $metadata['downloads'] >= $metadata['max_downloads'], 404); return $next($request); } }