In StreamServe, need to send JPEG as Base64 in HTTP response

Options

I have a project in which I need the create a JPEG and return it in HTTP response encoded as base64. The issue is when I generate the JPEG via Storyteller, the file is not available until after the response is sent. I tried to write the JPEG as a variable so I can use Base64EncodeString, but I cannot seem to figure out how to do so. Currently I the external app does 2 passes: one to generate the jpeg file and generate a file to use in an execute function to run "type filename" (where filename is custom for that run); and one to convert to run Base64EncodeFile to convert the JPEG to base64.

I am completely open to finding a better way. Any input would be greatly appreciated.

Comments

  • Template Engine would be your friend here.

    You could activate your jpeg creating process and send output to an attachment connector / or use a resource filter.

    You can now kick off a Template Engine script that references the attachment / resource (retrieving it in base64) and save the output to a variable.

    This variable can then be used in your response.

    Personally I like to have a thorough level of control on this kind of operation and would write a micro-service to do it.

    Good luck!