See the answer of Jonathan and me on a similar question. I hope this will help you out.
You can use the
storeFileDocumentContent(IContext context, IMendixObject fileDocument, java.io.InputStream inputStream)
method to store a file on your server into a FileDocument
.