Page 1 of 1

Mime to XML

Posted: Fri Nov 12, 2021 7:19 am
by nekbmm
Has anyone worked with the curl_mime _... functions I need to insert a .pdf file into XML, as the following example. Is there hbcurl.a for HMG_3.4.4?

Code: Select all

curlHandle: = curl_easy_init ()
mime = curl_mime_init (curlHandle)
  / * Add the attachment. * /
part = curl_mime_addpart (mime)
curl_mime_filedata (part, "Invoicexxx.pdf")
curl_mime_encoder (part, "base64")
? '<cbc: EmbeddedDocumentBinaryObject mimeCode = "application / pdf">' + part + '</ cbc: EmbeddedDocumentBinaryObject>'
Thanks in advance.
Nexbmm

Re: Mime to XML

Posted: Fri Nov 12, 2021 12:06 pm
by edk
I guess the usual base64 encoding is enough, at least in the XML I was generating that was how it worked. Got a sample XML file?

Code: Select all

Base64part := HB_Base64Encode( FileStr ( cPathPdf ) )
cXml := '<cac:Attachment>' + CRLF
cXml += '<cbc:EmbeddedDocumentBinaryObject mimeCode="application/pdf">' + Base64part + '</cbc:EmbeddedDocumentBinaryObject>' + CRLF
cXml += '</cac:Attachment>' + CRLF

Re: Mime to XML

Posted: Fri Nov 12, 2021 2:02 pm
by nekbmm
I've tried it, it works perfectly!
Thanks edk!