Make sure ParseFile is empty.

My ParseUser class has its own column named "profile_photo" which is the ParseFile for the photo. I have attached a photo file to a ParseUser instance and I can see in the application control panel that the profile_photo column for this user is filled with this file, and other users have "undefined" for this column as expected. Now in my code I need to check if the user has a profile photo attached or not. How should I do it. I tried to check that with isDataAvailable (), but it always returns true even if the value for profile_photo is "undefined" in the toolbar. I've also tried the following:

ParseFile photo = user.get("profile_photo");
photo.getDataInBackground(new GetDataCallback() { 
   @Override public void done(byte[] data, ParseException pfe) { 
      if(pfe == null) { 
         // byte array data always returns something! data.length > 0, always, even for undefined... 
       }
   }
});

      

But as you can see from the comments, the dataset is never empty, even if the ParseFile associated with the ParseUser in question is "undefined".

I would really appreciate it if you could tell me or point me to a way to clearly determine if a parsefile is empty or not.

Regards

+3


source to share


1 answer


You are using the wrong method to get your file. If you use get("column_name")

on a column ParseFile

, this method will return the file id. Instead, you should use

ParseFile file = object.getParseFile("column_name");

      



which will return null if the file is undefined.

+3


source







All Articles