Skip to content

Commit

Permalink
fix: Adding factory extensions for Optional StorageBucket (#3826)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebaland committed Aug 27, 2024
1 parent 199027f commit d53a467
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Amplify/Categories/Storage/StorageBucket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public extension StorageBucket where Self == ResolvedStorageBucket {
}
}


/// Conforms to `StorageBucket`. Represents a Storage Bucket defined by a name in the AmplifyOutputs file.
///
/// - Tag: OutputsStorageBucket
Expand All @@ -64,3 +63,19 @@ public struct OutputsStorageBucket: StorageBucket {
public struct ResolvedStorageBucket: StorageBucket {
public let bucketInfo: BucketInfo
}

public extension Optional where Wrapped == any StorageBucket {
/// References a `StorageBucket` in the AmplifyOutputs file using the given name.
///
/// - Parameter name: The name of the bucket
static func fromOutputs(name: String) -> (any StorageBucket)? {
return OutputsStorageBucket.fromOutputs(name: name)
}

/// References a `StorageBucket` using the data from the given `BucketInfo`.
///
/// - Parameter bucketInfo: A `BucketInfo` instance
static func fromBucketInfo(_ bucketInfo: BucketInfo) -> (any StorageBucket)? {
return ResolvedStorageBucket.fromBucketInfo(bucketInfo)
}
}

0 comments on commit d53a467

Please sign in to comment.