Reputation: 305
For my ParseUsers, there is a column named "profilePicture" of type ParseFile, and given a user I try to retrieve the ParseFile and convert it to Bitmap with the following code:
ParseUser user = ParseUser.getCurrentUser();
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 4;
Bitmap image = null;
ParseFile profilePicture = user.getParseFile("profilePicture");
System.out.println("DATA: " + profilePicture.isDataAvailable());
try {
InputStream inputStream = profilePicture.getDataStream();
image = BitmapFactory.decodeStream(inputStream, null, options);
} catch (ParseException e) {
e.printStackTrace();
}
return image;
Getting the ParseFile works fine, but every single time isDataAvailable() will return false, even though I manually check the column to ensure that there is an image file in the "profilePicture" column for that particular user. What could be the cause of this?
Upvotes: 0
Views: 55
Reputation: 17691
Use .getDataInBackground
method and decode your file in the done()
method
profilePicture.getDataInBackground(new GetDataCallback() {
@Override
public void done(byte[] data, ParseException e) {
// Do your magic
}
});
Upvotes: 1