Forum Discussion

KevinSaquing's avatar
6 years ago

Encode file to base64

Hi All,

Good day! I would like to ask if there's a way to encode file to base64?  I am using the http.request.uploads to get the files details on my custom endpoint but the upload object only return the name, size and mimeType.

Thanks in advance!

  • DougS's avatar
    DougS
    Khoros Oracle

    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):

    restBuilder

    Thanks,

    -Doug