Skip to content

Commit 6e19413

Browse files
authored
fix: Adding factory extensions for Optional StorageBucket (#3826)
1 parent 0425e51 commit 6e19413

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

Amplify/Categories/Storage/StorageBucket.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public extension StorageBucket where Self == ResolvedStorageBucket {
5050
}
5151
}
5252

53-
5453
/// Conforms to `StorageBucket`. Represents a Storage Bucket defined by a name in the AmplifyOutputs file.
5554
///
5655
/// - Tag: OutputsStorageBucket
@@ -64,3 +63,19 @@ public struct OutputsStorageBucket: StorageBucket {
6463
public struct ResolvedStorageBucket: StorageBucket {
6564
public let bucketInfo: BucketInfo
6665
}
66+
67+
public extension Optional where Wrapped == any StorageBucket {
68+
/// References a `StorageBucket` in the AmplifyOutputs file using the given name.
69+
///
70+
/// - Parameter name: The name of the bucket
71+
static func fromOutputs(name: String) -> (any StorageBucket)? {
72+
return OutputsStorageBucket.fromOutputs(name: name)
73+
}
74+
75+
/// References a `StorageBucket` using the data from the given `BucketInfo`.
76+
///
77+
/// - Parameter bucketInfo: A `BucketInfo` instance
78+
static func fromBucketInfo(_ bucketInfo: BucketInfo) -> (any StorageBucket)? {
79+
return ResolvedStorageBucket.fromBucketInfo(bucketInfo)
80+
}
81+
}

0 commit comments

Comments
 (0)