You should be working with an entity that is a generalisation of a FileDocument. In your Java Action call the getMendixObject() method on the proxy class for that entity to get a suitable object to use in the return statement.
https://docs.mendix.com/howto/data-models/working-with-images-and-files/#1-introduction
Hope this helps.
In Java in the return statement you can just do:
return fileDocument.getMendixObject();