We have integrated our Salesforce instance with one of the third party app and now they want to send us a pdf file as a response in Multipart format. Below is the sample of incoming response. We want to use this Multipart 'Content-Type' data and create/upload a pdf file to the related object in Salesforce. I was wondering if someone has experience in parsing this and can help me to understand how can I process this Multipart 'Content-Type' in Apex REST or REST API. Any help is much appreciated.
Header
Content-Length=161143&Content-Type=multipart%2fform-data%3b+boundary%3d----------------------------6d848496489849&Expect=100-continue&Host=localhost%3a1251
POST DATA
05003000000D8cuI251515afagwgagaw
------------------------------6d848496489849
Content-Disposition: form-data; name="WidgetID";
Hello
------------------------------6d848496489849
Content-Disposition: form-data; name="Widgetname";
World
------------------------------6d848496489849
Content-Disposition: form-data; name="jsonData"; filename="jsonData"
Content-Type: application/json
{"widget":{"debug":"on","window":{"title":"Sample Konfabulator Widget","name":"main_window","width":500,"height":500},"image":{"src":"Images/Sun.png","name":"sun1","hOffset":250,"vOffset":250,"alignment":"center"},"text":{"data":"Click Here","size":36,"style":"bold","name":"text1","hOffset":250,"vOffset":100,"alignment":"center","onMouseUp":"sun1.opacity = (sun1.opacity / 100) * 90;"}}}
------------------------------6d848496489849
Content-Disposition: form-data; name="pdffile"; filename="pdffile"
Content-Type: application/pdf
%PDF-1.0
… PDF file…
------------------------------6d848496489849
getParameters()
could be used to automatically split apart the parts for you.