Slide 29
Slide 29 text
class Image: Object {
enum Size {
case large
case medium
case small
case thumbnail
case original
}
func getRef(of size: Size) -> StorageReference? {
let path: String?
switch size {
case .large:
path = [largeRefPath, mediumRefPath, smallRefPath, thumbnailRefPath, originalRefPath].compactMap { $0 }.first
case .medium:
path = [mediumRefPath, largeRefPath, smallRefPath, thumbnailRefPath, originalRefPath].compactMap { $0 }.first
case .small:
path = [smallRefPath, mediumRefPath, largeRefPath, thumbnailRefPath, originalRefPath].compactMap { $0 }.first
case .thumbnail:
path = [thumbnailRefPath, smallRefPath, mediumRefPath, largeRefPath, originalRefPath].compactMap { $0 }.first
case .original:
path = originalRefPath
}
guard let refPath = path else { return nil }
return Storage.storage().reference().root().child(refPath)
}
}
4XJGU