Skip to content

IOS/Swift Retrieve file field after login throws error code: 151 (version: 1.12) #812

@leonardojobim

Description

@leonardojobim

The code below works well if the user had signed up and didn't log out yet.
But if the user logs out and then logs in again, it throws the following error: [Error]: Can't download a file that doesn't exist on the server or locally. (Code: 151, Version: 1.12.0)
Apparently, login function is not retrieving extra file fields properly:

if let user = PFUser.currentUser() {
  if let photo = user["profilePhoto"] as? PFFile {
    photo.getDataInBackgroundWithBlock({ (data: NSData?, error: NSError?) -> Void in
      dispatch_async(dispatch_get_main_queue(), {
        if let data = data {
          self.profileImageView.image = UIImage(data: data)
        }
      })
    })
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions