Convert base64 encoded string back to image in flow

I have received a base64 encoded image from source system via REST post.
I need to convert this back to an image and write on the file system of the IS.

How do I generate back the image from a string of the based64 encoded image?
Any suggestions?

You can use “pub.string:base64Decode” service to convert inbound base64Encoded string to byte array and then you can use one of the below approaches:

  1. If proper allowAccess permissions are setup on the IS to target file path then you can use “pub.file:bytesToFile” to write the above byte array to file

OR

  1. write some simple java service (below is a sample code snippet) to write the byte array to file system.
FileOutputStream fos = new FileOutputStream("pathname");
fos.write(myByteArray);
fos.close();

Hi Prasad,

I have gone with this approach suggested by you,

  1. If proper allowAccess permissions are setup on the IS to target file path then you can use “pub.file:bytesToFile” to write the above byte array to file

But when I open the tif image created in this way, it says it is not a valid image.

When I compare the base64 Encoded string which was initially sent by source system, and what was received by webMethods via Rest post, I see some addition ‘+’ signs added at the end of each line of the string.

Any comments, further advice?

Oh yeah… you may have to ask the sender/source to URL Encode the base64EncodedString (if webMethods, use pub.string:URLEncode) and as a first step of your target service URL decode the inbound string using pub.string:URLDecode

Hope this helps…