Adding binary file to XML data in http post


I have a requirement to add attachment to XML data and send it using http post. The attachment could be a text file or a binary file (Picture or PDF or anything). The limit on attachment file size is 5 MB.

Could any one please let me know what could be the best way of doing this? One of the approach which came in my mind is mentioned below. Could anyone please let me know if this is a good way of doing it.

Get the attachment from the FTP location, get the data in string and use base64 encoding to encode the data and put it in a xml field and send it along with XML data in http post.

Will the file size of 5 MB could have a negative impact on processing time?

I would be greatly obliged if you could help me in this regard.


If it were me I’d POST a document of type multipart/form-data that had the XML and the attachment in two separate parts. See RFC 2388.

Thank you Curtis.