EmbeddedFileBinaryObject

Hi, I am working with the API to generate telecom bills to customers straight from my VOIP gateway on a monthly basis. I need to attached their Call records as a PDF to their Invoice so they can download and check the calls made. I have done this manually ( very time consuming for 50 companies!) for some time and now its just too time consuming.

I have looked at the document upload type for attaching the ducument to an Invoice ID and notice the Cdata ( EmbeddedFileBinaryObject). I cannot find any examples for getting/generating the neccessary info for this XML field and have become rather stuck. Help most appreciate

Hi @Howard

The file needs to be supplied as a base64 encoding of the file itself.

What programming language are you using? Perhaps I can find an example for you?

Hi Mathew

I’m using XML with cURL in PHP on Centos.

I have the PDF’s generated from mariadb (outfile)

many thanks

Ok, great. So that file I’m assuming is saved locally, or returned as a string?

If it’s the former, you can do something like this:

/** Get the contents of the file */
$file = file_get_contents("../path/to/file.pdf"); 

If it’s in a string already, then no need to do this as that step would load the file into a string for you. From there, you encode the string using Base64:

/** Take the file string and encode it using Base64 */
$data = base64_encode($file); `

When it comes to compiling the XML, you set the value of EmbeddedFileBinaryObject to the new base64 string.

I hope that helps?

Nice, makes sense now

thanks will try now

1 Like

Thanks Mathew

Uploaded ok

regards
Howard :grinning:

1 Like

No problem at all! Any further queries, please don’t hesitate to ask :slightly_smiling_face:

This topic was automatically closed after 6 days. New replies are no longer allowed.