releaseStorageRulesetFromSource method
Creates a new Ruleset from the given source, and applies it to a Cloud Storage bucket.
source - Rules source to apply.
bucket - Optional name of the Cloud Storage bucket to apply the rules on. If
not specified, applies the ruleset on the default bucket configured via
AppOptions.storageBucket.
Returns a future that fulfills when the ruleset is created and released.
Implementation
Future<Ruleset> releaseStorageRulesetFromSource(
String source, [
String? bucket,
]) async {
// Bucket name is not required until the last step. But since there's a createRuleset step
// before then, make sure to run this check and fail early if the bucket name is invalid.
_getBucketName(bucket);
final rulesFile = RulesFile(name: 'storage.rules', content: source);
final ruleset = await createRuleset(rulesFile);
await releaseStorageRuleset(ruleset.name, bucket);
return ruleset;
}