E9.2 B64-encoded PDF stream from API to Media Object

DaveWagoner

DaveWagoner

VIP Member
Hi folks, got a big one here.

I am calling an API that returns a B64-encoded string which is a PDF file. The goal is to get that file, as a true PDF, into a media object queue.

Anyone done this using orch? I'm a bit stuck and brain-fried at the moment!
 
Weird timing just now finished working on something similar going the other direction.

Anyway, in your case I believe you use Python so see if have access to the base64 Python Library (Groovy and Ruby should have equivialent libs). Using Python you should be able to decode the B64 string to a byte array (the PDF file) directly in the Orchestration and then, if your version of Orchestrator supports attachments, I think you should be able to save the attachment to the JDE business object (sales order, purchase order, etc.) directly in Orchestrator (from what I have read).

Our version of Orchestrator doesn't support attachments so I am doing this at the BSFN layer with an Orch wrapper so all of my attachment/media object and B64 stuff is done in C. If your version of Orchestrator doesn't support attachments you can still do what you want but you will need to do it in C BSFNs like I am doing. In short I chunk the B64 data in a series of BSFN calls and encode/decode in C and read/write to the media objects using the C media object API.
 
Just to add on to @BOster's response, after you decode the string into a byte array, write it to a file in your temporary session folder. Return the file name to the orchestration so it can be passed into the Attachment UDO.

For those on a tools release earlier than 9.2.6, the media object api will allow you to create the file attachment. You can view the documentation on how to call it here.
 
Hi folks, got a big one here.

I am calling an API that returns a B64-encoded string which is a PDF file. The goal is to get that file, as a true PDF, into a media object queue.

Anyone done this using orch? I'm a bit stuck and brain-fried at the moment!
Hi Dave, you need a groove or jruby in order to do this task. Here i send you an example on Jruby
 

Attachments

  • Base64ToPDF.zip
    12.9 KB · Views: 6
Hi Dave, you need a groove or jruby in order to do this task. Here i send you an example on Jruby
This is great!! Thank you.

Do we also need to handle cleanup after we action the file, or is this some sort of temp storage that goes away every so often?

Thanks again!
 
This is great!! Thank you.

Do we also need to handle cleanup after we action the file, or is this some sort of temp storage that goes away every so often?

Thanks again!
The file store in a temp folder from AIS, I think is better delete the file, but you can always clean temp files from server when you request some space.
 
The file store in a temp folder from AIS, I think is better delete the file, but you can always clean temp files from server when you request some space.
I did a little testing, the temp directory and all contents get wiped out at the end of a session. Self cleaning!! Nice to have that handled on the infra side.
 
Back
Top