Skip to content

Commit 24089ae

Browse files
authored
Merge pull request #5476 from aws-amplify/storage-output-update
feat(core): update storage outputs class for multi-bucket support
2 parents 6055a80 + e7906c7 commit 24089ae

File tree

5 files changed

+132
-10
lines changed

5 files changed

+132
-10
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import 'package:amplify_core/amplify_core.dart';
5+
6+
part 'bucket_outputs.g.dart';
7+
8+
/// {@template amplify_core.amplify_outputs.bucket_outputs}
9+
/// The Amplify Gen 2 outputs for Buckets in the Storage category.
10+
/// {@endtemplate}
11+
@zAmplifyOutputsSerializable
12+
class BucketOutputs
13+
with AWSEquatable<BucketOutputs>, AWSSerializable, AWSDebuggable {
14+
/// {@macro amplify_core.amplify_outputs.bucket_outputs}
15+
const BucketOutputs({
16+
required this.name,
17+
required this.bucketName,
18+
required this.awsRegion,
19+
});
20+
21+
factory BucketOutputs.fromJson(Map<String, Object?> json) =>
22+
_$BucketOutputsFromJson(json);
23+
24+
/// The user friendly name of the bucket
25+
final String name;
26+
27+
/// The Amazon S3 bucket name.
28+
final String bucketName;
29+
30+
/// The AWS region of Amazon S3 resources.
31+
final String awsRegion;
32+
33+
@override
34+
List<Object?> get props => [
35+
name,
36+
bucketName,
37+
awsRegion,
38+
];
39+
40+
@override
41+
String get runtimeTypeName => 'BucketOutputs';
42+
43+
@override
44+
Object? toJson() {
45+
return _$BucketOutputsToJson(this);
46+
}
47+
}

packages/amplify_core/lib/src/config/amplify_outputs/storage/bucket_outputs.g.dart

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/amplify_core/lib/src/config/amplify_outputs/storage/storage_outputs.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import 'package:amplify_core/amplify_core.dart';
5+
import 'package:amplify_core/src/config/amplify_outputs/storage/bucket_outputs.dart';
56

67
part 'storage_outputs.g.dart';
78

@@ -12,7 +13,11 @@ part 'storage_outputs.g.dart';
1213
class StorageOutputs
1314
with AWSEquatable<StorageOutputs>, AWSSerializable, AWSDebuggable {
1415
/// {@macro amplify_core.amplify_outputs.storage_outputs}
15-
const StorageOutputs({required this.awsRegion, required this.bucketName});
16+
const StorageOutputs({
17+
required this.awsRegion,
18+
required this.bucketName,
19+
this.buckets,
20+
});
1621

1722
factory StorageOutputs.fromJson(Map<String, Object?> json) =>
1823
_$StorageOutputsFromJson(json);
@@ -23,8 +28,11 @@ class StorageOutputs
2328
/// The Amazon S3 bucket name.
2429
final String bucketName;
2530

31+
/// The list of buckets if there are multiple buckets for the project
32+
final List<BucketOutputs>? buckets;
33+
2634
@override
27-
List<Object?> get props => [awsRegion, bucketName];
35+
List<Object?> get props => [awsRegion, bucketName, buckets];
2836

2937
@override
3038
String get runtimeTypeName => 'StorageOutputs';

packages/amplify_core/lib/src/config/amplify_outputs/storage/storage_outputs.g.dart

Lines changed: 21 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/amplify_core/test/config/amplify_outputs/test_data.dart

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,26 @@ const amplifyoutputs = '''{
9999
]
100100
},
101101
"storage": {
102-
"aws_region": "oem dks",
103-
"bucket_name": "dolor et esse"
104-
},
102+
"aws_region": "us-east-2",
103+
"bucket_name": "amplifyTeamDrive-one-stora-testbucketgen2bucket0b8c-9ggcfqfunkjr",
104+
"buckets": [
105+
{
106+
"name": "amplifyTeamDrive-one",
107+
"bucket_name": "amplifyTeamDrive-one-stora-testbucketgen2bucket0b8c-9ggcfqfunkjr",
108+
"aws_region": "us-east-2"
109+
},
110+
{
111+
"name": "amplifyTeamDrive-two",
112+
"bucket_name": "amplifyTeamDrive-two-stora-testbucketgen2bucket0b8c-2",
113+
"aws_region": "us-east-2"
114+
},
115+
{
116+
"name": "amplifyTeamDrive-three",
117+
"bucket_name": "amplifyTeamDrive-three-stora-testbucketgen2bucket0b8c-3",
118+
"aws_region": "us-east-2"
119+
}
120+
]
121+
},
105122
"version": "1"
106123
}
107124
''';

0 commit comments

Comments
 (0)