I am using the code below to sign up a user with username, password, and a profile picture.
func createUserwithAllFields() {
let profileImageData = UIImageJPEGRepresentation(profileAvatar.image, 0.6)
//let profileImageData = UIImageJPEGRepresentation(profileImg, 0.6)
let profileImageFile = PFFile(data: profileImageData)
if tv_username.text != ""
&& tv_password.text != ""
{
var user = PFUser()
user.username = tv_username.text
user.password = tv_password.text
user["profileImage"] = profileImageFile
user.signUpInBackgroundWithBlock({ (success, error) -> Void in
if error == nil {
//if SignUp is successful
let installation = PFInstallation.currentInstallation()
installation["user"] = user
installation.saveInBackgroundWithBlock(nil)
//self.showChatOverview()
self.goToMainScreen()
} else {
}
})
}else{
}
}
When I look at he User
class on parse.com there is a file that get's uploaded (see screenshot below)
Although there is a file, when I click on it and download it, I open it to find a blank (i.e. white) image.
The profileAvatar
is a UIImageView
in the ViewController and it does point to a valid image because I can see that when I run the app.
This is the blank image that I see:
In parse you need to first save the user and after save the image, I modify your code to accomplish that: