File tree Expand file tree Collapse file tree 6 files changed +77
-0
lines changed
packages/amplify_core/lib/src/types Expand file tree Collapse file tree 6 files changed +77
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ part 'network_exception.dart';
21
21
part 'push/push_notification_exception.dart' ;
22
22
part 'storage/access_denied_exception.dart' ;
23
23
part 'storage/http_status_exception.dart' ;
24
+ part 'storage/invalid_storage_bucket_exception.dart' ;
24
25
part 'storage/local_file_not_found_exception.dart' ;
25
26
part 'storage/not_found_exception.dart' ;
26
27
part 'storage/operation_canceled_exception.dart' ;
Original file line number Diff line number Diff line change
1
+ part of '../amplify_exception.dart' ;
2
+
3
+ /// {@template amplify_core.storage.invalid_storage_bucket_exception}
4
+ /// Exception thrown when the [StorageBucket] is invalid.
5
+ /// {@endtemplate}
6
+ class InvalidStorageBucketException extends StorageException {
7
+ const InvalidStorageBucketException (
8
+ super .message, {
9
+ super .recoverySuggestion,
10
+ super .underlyingException,
11
+ });
12
+
13
+ @override
14
+ String get runtimeTypeName => 'InvalidStorageBucketException' ;
15
+ }
Original file line number Diff line number Diff line change
1
+ /// {@template amplify_core.storage.bucket_info}
2
+ /// Presents a storage bucket information.
3
+ /// {@endtemplate}
4
+ class BucketInfo {
5
+ /// {@macro amplify_core.storage.bucket_info}
6
+ const BucketInfo ({required this .bucketName, required this .region});
7
+ final String bucketName;
8
+ final String region;
9
+ }
Original file line number Diff line number Diff line change
1
+ import 'package:amplify_core/src/config/amplify_outputs/storage/storage_outputs.dart' ;
2
+ import 'package:amplify_core/src/types/storage/bucket_info.dart' ;
3
+ import 'package:amplify_core/src/types/storage/storage_bucket_from_outputs.dart' ;
4
+ import 'package:meta/meta.dart' ;
5
+
6
+ /// Presents a storage bucket.
7
+ class StorageBucket {
8
+ /// Creates a [StorageBucket] from [BucketInfo] .
9
+ const StorageBucket .fromBucketInfo (this ._info);
10
+
11
+ /// Creates a [StorageBucket] defined by the [name] in AmplifyOutputs file.
12
+ factory StorageBucket .fromOutputs (String name) =>
13
+ StorageBucketFromOutputs (name);
14
+
15
+ final BucketInfo _info;
16
+
17
+ @internal
18
+ BucketInfo resolveBucketInfo (StorageOutputs ? storageOutputs) => _info;
19
+ }
Original file line number Diff line number Diff line change
1
+ import 'package:amplify_core/amplify_core.dart' ;
2
+ import 'package:amplify_core/src/config/amplify_outputs/storage/storage_outputs.dart' ;
3
+ import 'package:meta/meta.dart' ;
4
+
5
+ /// {@template amplify_core.storage.storage_bucket_from_outputs}
6
+ /// Creates a [StorageBucket] defined by the name in AmplifyOutputs file.
7
+ /// {@endtemplate}
8
+ @internal
9
+ class StorageBucketFromOutputs implements StorageBucket {
10
+ /// {@macro amplify_core.storage.storage_bucket_from_outputs}
11
+ const StorageBucketFromOutputs (this ._name);
12
+
13
+ final String _name;
14
+
15
+ @override
16
+ BucketInfo resolveBucketInfo (StorageOutputs ? storageOutputs) {
17
+ assert (
18
+ storageOutputs != null ,
19
+ const InvalidStorageBucketException (
20
+ 'Amplify Storage is not configured.' ,
21
+ recoverySuggestion:
22
+ 'Make sure storage exists in the Amplify Outputs file.' ,
23
+ ),
24
+ );
25
+ // TODO(nikahsn): fix after adding buckets to StorageOutputs.
26
+ return BucketInfo (
27
+ bucketName: _name,
28
+ region: storageOutputs! .awsRegion,
29
+ );
30
+ }
31
+ }
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ export '../exception/amplify_exception.dart'
11
11
StorageOperationCanceledException,
12
12
NetworkException,
13
13
UnknownException;
14
+ export 'bucket_info.dart' ;
14
15
export 'copy_operation.dart' ;
15
16
export 'copy_options.dart' ;
16
17
export 'copy_request.dart' ;
@@ -44,6 +45,7 @@ export 'remove_operation.dart';
44
45
export 'remove_options.dart' ;
45
46
export 'remove_request.dart' ;
46
47
export 'remove_result.dart' ;
48
+ export 'storage_bucket.dart' ;
47
49
export 'storage_item.dart' ;
48
50
export 'storage_path.dart' ;
49
51
export 'transfer_progress.dart' ;
You can’t perform that action at this time.
0 commit comments