swiftmacosparse-platformlocal-storagepffile

Parse Error Code 151


I have the following PFObject saved locally:

<Local: 0x6180000a4080, objectId: SAMPLEID, localId: (null)> {
    ACL = "<PFACL: 0x60800002f0a0>";
    image = "<PFFile: 0x60800005e7b0>";
    name = Anonymous;
}

I'm trying to run the following code to retrieve the image:

let query = PFQuery(className: "Local")
query.fromLocalDatastore()
query.findObjectsInBackgroundWithBlock { (objects: [PFObject]?, error: NSError?) -> Void in
   if let objects: [PFObject] = objects {
      for object in objects {
         let imageFile = object["image"] as! PFFile
         imageFile.getDataInBackgroundWithBlock {
            (imageData: NSData?, error: NSError?) -> Void in
               if error == nil {
                  if let imageData = imageData {
                     let image = NSImage(data:imageData)
                  }
               }
            }
         }
      }
   }

Parse is giving me the following error: Can't download a file that doesn't exist on the server or locally. (Code: 151, Version: 1.11.0)


Solution

  • I had the same issue trying to load a file I had loaded dozens of times before. I hadn't change the file, but I did save the same image multiple times. It seemed like there was a glitch with parse saving for some reason. I changed nothing, but just re-saved the same image once again and it worked fine.