什么是提供的桶?

问题描述 投票:0回答:1

我正在观看教程,我想使用现有的代码编写并将其添加到我的firebase中。我已成功创建帐户并导入已下载的GoogleService-Info。在那里没有其他修改

现在我想创建一个用户,但它不起作用。

我收到此错误:

'NSInvalidArgumentException',原因:'提供的存储桶:random.appspot.com与当前实例的存储桶不匹配:random2.appspot.com'

内部火力储存:

service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read, write: if request.auth != null;
    }
  }
}

在Swift里面:

 static func signUp(username: String, email: String, password: String, imageData: Data, onSuccess: @escaping () -> Void, onError:  @escaping (_ errorMessage: String?) -> Void) {
        Auth.auth().createUser(withEmail: email, password: password) { (authData: AuthDataResult?, error: Error?) in
            if error != nil {
                onError(error!.localizedDescription)
                return
            }
            let uid = authData!.user.uid
            let storageRef = Storage.storage().reference(forURL: Config.STORAGE_ROOF_REF).child("profile_image").child(uid)
            storageRef.putData(imageData, metadata: nil, completion: { (_, error: Error?) in
                if error != nil {
                    return
                }
                storageRef.downloadURL(completion: { (url: URL?, error: Error?) in
                    if let profileImageUrl = url?.absoluteString {
                        self.setUserInfomation(profileImageUrl: profileImageUrl, username: username, email: email, uid: uid, onSuccess: onSuccess)
                    }
                })
            })
        }
    }

我可以看到在我的firebase中创建的用户,但就是这样。另一方面,配置文件图像不起作用。即使存储已激活。有什么建议?

swift firebase firebase-storage
1个回答
0
投票

正如错误所说配置在这里STORAGE_ROOF_REF

let storageRef = Storage.storage().reference(forURL: Config.STORAGE_ROOF_REF)

应该是random2.appspot.com而不是random.appspot.com,最好还是自动化

let storageRef = Storage.storage().reference()
storageRef.putData//////

要将铲斗头添加到firebase控制台>存储选项卡,然后单击右侧菜单(它包含计费)

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.