I am using File System Storage adapter to save uploaded files on the parse server. In my app each user can have profile photo. when the user wants to change his photo, the old one should be deleted from the server. But the old image remains unchanged. It leads to fill the server storage after some time. Here is my code:
public void update (Uri uri)
{
ParseUser user = ParseUser.getCurrentUser();
if(uri!=null){
InputStream iStream=getContentResolver().openInputStream(uri);
byte[]image=Helper.getBytes(iStream);
ParseFile file=new ParseFile("profile.png",image);
file.saveInBackground();
user.put("photo",file);
user.saveInBackground();
}
}
Unfortunately Android SDK does not have a function to delete the file but you can do that using Cloud Code Functions or maybe a trigger. Something like this should solve your problem: