2

我在注册期间上传图片时遇到问题。有一个 blobID 属性。你能告诉我如何为新用户生成唯一的 blobid。我检查了虚拟整数值。我发现这个 blobid 与这个用户 ID 没有关联的错误。请为此提供更好的解决方案。

4

2 回答 2

1

You should do next tasks:

  1. Sign Up user
  2. Sign In user
  3. Create blob and Upload file - you will receive blobID of new file
  4. Update user's blobID field - just set blobID from step 3
于 2013-05-29T08:50:27.817 回答
1

使用 SWIFT。popUp 功能让用户知道他们已成功添加。

func addUser() {

    // add new user

    let newUser:QBUUser = QBUUser()

    newUser.password = pwTxt.text
    newUser.fullName = unTxt.text
    newUser.email = emTxt.text


    QBRequest.signUp(newUser, successBlock: { (response) in

        self.popUp("Signup Success!", msg:"You are now signed up!", button1: "OK!")

        // You must be logged in to upload an avatar/image file        
        QBRequest.logIn(withUserEmail: self.emTxt.text!, password: self.pwTxt.text!, successBlock: { (response: QBResponse, user) in

            QBRequest.tUploadFile(imgData, fileName: "image.png", contentType: "image/png", isPublic: true, successBlock: { (response, blob) in

             }, statusBlock: { (request, status) in
                        print("Upload Succcess!")

             }, errorBlock: { (response) in
                        print("Upload Failure!")
             })

         }, errorBlock: { (response: QBResponse) in
                    print("Sign In Failed")
         })

         }, errorBlock: { (response) in
                    print("Error in SignUp")

         })
 }


func popUp (_ title: String, msg: String, button1: String){


    print("\(title)")
    print("\(msg)")

    let alert = UIAlertController(title: "\(title)", message: "\(msg)", preferredStyle: UIAlertControllerStyle.alert)

    self.present(alert, animated: true, completion: nil)

    alert.addAction(UIAlertAction(title: "\(button1)", style: .default, handler: {
        action in
        alert.dismiss(animated: true, completion: nil)
    }))

}
于 2016-12-18T06:09:36.133 回答