我正在使用登录创建一个简单的应用程序,使用firebase注册尝试实现图像上传功能,但会出现以下错误。因为我是新手,所以非常感谢帮助。
import Foundation
import Firebase
import FirebaseAuth
import FirebaseStorage
import FirebaseDatabase
let roofRef = FIRDatabase.database().reference()
class DataService {
static let dataService = DataService()
private var _BASE_REF = roofRef
private var _users_REF = roofRef.child("users")
var BASE_REF: FIRDatabaseReference{
return _BASE_REF
}
var storageRef: FIRStorageReference {
return FIRStorage.storage().reference()
}
var fileUrl: String!
func SignUp(username: String, email: String, Password: String, data: NSData)
{
FIRAuth.auth()?.createUser(withEmail: email, password: Password, completion: { (user, error) in
if let error = error{
print(error.localizedDescription)
}
let changeRequest = user?.profileChangeRequest()
changeRequest?.displayName = username
changeRequest?.commitChanges(completion: { (error) in
if let error = error {
print(error.localizedDescription)
return
}
})
let filePath = "profileImage/\(user!.uid)"
let metadata = FIRStorageMetadata()
metadata.contentType = "image/jpeg"
self.storageRef.child(filePath).putData(data, metadata: metadata, completion: { (metadata, error) in
if let error = error {
print("\(error.description)")
return
}
self.fileURL = metadata?.downloadURLs![0].absoluteString
let changeRequestPhoto = user!.profileChangeRequest()
changeRequestPhoto.photoURL = NSURL(string: self.fileURL)
changeRequestPhoto.commitChangesWithCompletion({ (error) in
if let error = error {
print(error.localizedDescription)
return
} else {
print("profile update")
}
})
let appDelegate: AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
appDelegate.login()
})
})
}
}
答案 0 :(得分:0)
尝试使用此代码>>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<div class="content">
</div>
<div class="menu">
<span class="current" style="">United States</span>
<ul class="list">
<li class="option">United Arab Emirates</li>
<li class="option">United States</li>
</ul>
</div>
</div>