createRoomStorageConnection method
Future<StorageConnection>
createRoomStorageConnection({
- required String projectId,
- required String roomName,
- required String name,
- required StorageConnectionConfig config,
- StorageConnectionCredentials? credentials,
Implementation
Future<StorageConnection> createRoomStorageConnection({
required String projectId,
required String roomName,
required String name,
required StorageConnectionConfig config,
StorageConnectionCredentials? credentials,
}) async {
if (config.anonymous == (credentials != null)) {
throw ArgumentError('Anonymous access must omit credentials; authenticated access requires credentials');
}
if (credentials != null && config.provider != credentials.provider) throw ArgumentError('Storage credential provider mismatch');
final response = await httpClient.post(
_storageConnectionsUri(projectId, roomName),
body: jsonEncode({'name': name, 'config': config.toJson(), 'credentials': credentials?.toJson()}),
);
_checkStorageConnectionResponse(response);
return StorageConnection.fromJson(jsonDecode(response.body) as Map<String, dynamic>);
}