Base64 String To Image In Mule
In this tutorial we will demonstrate how to convert Base64 String To Image In Mule
To create the image we would require the base64 content, to demonstrate I have converted a sample image file to base64 using below url and used the same base64 content to write the image in one of the local directory use file write operation.
Create a project in anypoint studio and configure the listener to trigger the flow
Convert base64 string to binary and use mime type as application/octet-stream as shown below
Use fromBase64 dataweave function to convert base64 to binary
Dataweave Expression
%dw 2.0 import * from dw::core::Binaries output application/octet-stream --- fromBase64(payload)
Reference: https://docs.mulesoft.com/mule-runtime/4.1/dw-binaries-functions-frombase64
Change the mime type to image/png
Write the file in one of the local directory using file write operation
Deploy and trigger the file, image is created in local directory
Sample tutorial: writeimagefile sample application
Hi Team,
Very nice website where all topics are covered in a single platform. Keep up the good work.
One input : Here SetPayload is not mandatory . Its automatically getting converted to different formats like jpeg,png ,gif etc without explicitly mentioning the Mime Type in SetPayload
Excellent material available for new beginers. Really liked your work !!!
Keep up good work, All the best !!!!!
Best website for beginners !!!