打开项目后,我总是会遇到这个问题。我该怎么办?
import UIKit
import Firebase
class FIRImage
{
var image: UIImage
var downloadURI: String?
var ref: StorageReference!
init(image: UIImage) {
self.image = image
}
}
extension FIRImage
{
func saveProfileImage(_ userUID: String, _ completion: @escaping (Error?) -> Void)
{
let resizedImage = image.resized()
let imageData = UIImageJPEGRepresentation(resizedImage, 0.9)
ref = StorageReference.profileImages.reference().child(userUID)
downloadURI = ref.debugDescription
ref.put(imageData!, metadata: nil) { (metaData, error) in
completion(error)
}
}
func save(_ uid: String, completion: @escaping (Error?) -> Void)
{
let resizedImage = image.resized()
let imageData = UIImageJPEGRepresentation(resizedImage, 0.9)
ref = StorageReference.images.reference().child(uid)
downloadURI = ref.debugDescription
refput(imageData!, metadata: nil) { (metaData, error) in
completion(error)
}
}
}
extension FIRImage
{
class func downloadProfileImage(_ uid: String, completion: @escaping (UIImage?, Error?) -> Void)
{
StorageReference.profileImages.reference().child(uid).data(withMaxSize: 1 * 1024 * 1024) { (imageData, error) in
if error == nil && imageData != nil {
let image = UIImage(data: imageData!)
completion(image, error)
} else {
completion(nil, error)
}
}
}