firebase和我的代码出现错误。
类型“ StorageReference”没有成员“ put”
我尝试了putData,什么也没有。解决此问题的最佳解决方案是什么?
当用户点击以选择个人资料照片时,我也会收到此错误
'UIImageJPEGRepresentation'已被实例方法替换 'UIImage.jpegData(compressionQuality:)'
StorageReference.put(imageData, metadata: nil, completion: { (metadata, error) in
if let profileImg = self.selectedImage, let imageData = UIImageJPEGRepresentation(profileImg, 0.1)
答案 0 :(得分:0)
另外一篇文章,介绍如何将数据上传到Firebase上的存储中:
https://firebase.google.com/docs/storage/ios/upload-files
// Upload the file to the path "images/rivers.jpg"
let uploadTask = riversRef.putData(data, metadata: nil) { (metadata, error) in
guard let metadata = metadata else {
// Uh-oh, an error occurred!
return
}
// Metadata contains file metadata such as size, content-type.
let size = metadata.size
// You can also access to download URL after upload.
riversRef.downloadURL { (url, error) in
guard let downloadURL = url else {
// Uh-oh, an error occurred!
return
}
}
}