Search code examples
iosparse-platformparse-cloud-codepfobjectpffile

Can't fetch parse file from PFObject


Trying to fetch a PFfile from PfObject but when I fetch value of a particular key , it only gives me a class name

Here is my CloudCode

Parse.Cloud.define("fetchBusinessWithID", function(request, response) {
  var query = new Parse.Query("Business");
  query.equalTo("uniqueBusinessID", request.params.businessId);
  query.find({
    success: function(results) {

      if(results.length > 0)
         {
         var fetchedObject = results[0];

         response.success(fetchedObject);
    }
    else
    {

         response.error("No Business Saved Yet");
    }



    },
    error: function() {
      response.error("Something Went wrong");
    }
  });
});

And this is on iOS

PFCloud callFunctionInBackground:@"fetchBusinessWithID"
                       withParameters:@{@"businessId": @"Madept2"}
                                block:^( PFObject *business, NSError *error) {

                                }];

When I see PFObject in Debug consoleenter image description here

So how can I fetch attributes of this file, as I can not parse full object of PfFile, Please help me on this, What I am doing wrong.

Here is my data Model

enter image description here


Solution

  • Get your image data with:

    PFFile *imageFile = [business objectForKey:@"aboutImage"];
    
    [imageFile getDataInBackgroundWithBlock:^(NSData *result, NSError *error) {
        if (error == nil) {
            UIImage *aboutImage = [UIImage imageWithData:result];
            // use your image
        }
    }];