integer('size'); throw_if(empty($size), BadRequestHttpException::class, 'A non-empty "size" query parameter must be provided.'); $model = Backup::query()->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. $server = $model->server; throw_if($server->node_id !== $node->id, HttpForbiddenException::class, 'Requesting node does not have permission to access this server.'); // Prevent backups that have already been completed from trying to // be uploaded again. throw_if(($model->completed_at) !== null, ConflictHttpException::class, 'This backup is already in a completed state.'); return new JsonResponse($presignBackupUpload->presign($model, $size)); } }