How to delete the contents of a FileDocument

1
I'm trying to delete the contents of a FileDocument, but that isn't possible in a microflow. Anyone with sample code for a java-action which has a FileDocument as an input parameter and only deletes the file content, not the object?
asked
1 answers
7

Write it with an empty stream as source.

Java action with filedocument as parameter type System.FileDocument

import java.io.ByteArrayInputStream;
import com.mendix.core.Core;
import com.mendix.systemwideinterfaces.core.UserAction;
import com.mendix.systemwideinterfaces.core.IMendixObject;

    // BEGIN USER CODE
    Core.storeFileDocumentContent(getContext(), filedocument.getMendixObject(), filedocument.getName(),  new ByteArrayInputStream("".getBytes("UTF-8")));
    return true;
    // END USER CODE
answered