我正在尝试与Firebase进行聊天,但出现此错误:类型“ StorageMetadata”的值没有以下代码的成员“ downloadURLs” :
var fileUrl: String!
func CreateNewRoom(user: User, caption: String, data: NSData) {
let filePath = "\(user.uid)/\(Int(NSDate.timeIntervalSinceReferenceDate))"
let metaData = StorageMetadata()
metaData.contentType = "image/jpg"
storageRef.child(filePath).putData(data as Data, metadata: metaData) { (metadata, error) in
if let error = error {
print("Error uploading: \(error as NSError)")
return
}
self.fileUrl = metadata!.downloadURLs![0].absoluteString
if let user = Auth.auth().currentUser {
let idRoom = self.BASE_REF.child("rooms").childByAutoId()
idRoom.setValue(["caption": caption, "thumbnailUrlFromStorage": self.storageRef.child(metadata!.path!).description, "fileUrl": self.fileUrl])
}
}
}
答案 0 :(得分:0)
StorageMetadata没有名为downloadURLs的属性,就像您在API documentation中所看到的那样。很久以前就已弃用该功能,并将其从API中删除。您可能正在看一个旧的示例或教程。
如果您需要generate a download URL for a file in Cloud Storage,请使用downloadURL()来获取一个。