Sorry for the late reply on this, and hopefully this is still relevant.
We don't support getting a Base64 of a file upload via a custom endpoint (it would require services work using a java plugin to build something that could do this). You should be able to create an endpoint that makes a REST API call to post a message and include an attachment with that -- you would want to do a multipart/form-data POST to your endpoint and then include the name of the field that contains the file in your post. This article has some good info on how to upload an attachment with your post using REST V2 over HTTP:
Create a message with an attachment (Community API V2)
This article has good info on how to make a REST V2 POST via Freemarker (using the restbuilder object):
Thanks,
-Doug