attributes->get('node'); $size = (int) $request->query('size'); if (empty($size)) { throw new BadRequestHttpException('A non-empty "size" query parameter must be provided.'); } $backup = Backup::where('uuid', $backup)->firstOrFail(); // Check that the backup is "owned" by the node making the request. This avoids other nodes // from messing with backups that they don't own. if ($backup->server->node_id !== $node->id) { throw new HttpForbiddenException('Requesting node does not have permission to access this server.'); } // Prevent backups that have already been completed from trying to be uploaded again. if (!is_null($backup->completed_at)) { throw new ConflictHttpException('This backup is already in a completed state.'); } // Ensure we are using the S3 schema. $schema = $this->backupService->get($backup->backupHost->schema); if (!$schema instanceof S3BackupSchema) { throw new BadRequestHttpException('The configured backup schema is not an S3 compatible.'); } return new JsonResponse($schema->getUploadParts($backup, $size)); } }