IDM Cloud - Transform PDF octet-stream to base64
Hi Everybody,
For one client i need to upload a pdf in IDM. i developed a dataflow and use IDM API to get the PDF content (using ION REST API IDM/api/items/{pid}/resource/stream). The APIs send an octet-stream.
Then, i try to merge it with a fusion python script in my ProcessContentDocument BOD. The script works.
Problem, the PDF comes to IDM perfectly but the content is damaged. I think that the base64 binary is wrong (maybe my python method is not well coded).
Do you have an idea please ?
Best Answers
-
Hello Pierrick - Below are the two lines of code I have successfully used with the octet-stream and getting a base64 encoded string. Hopefully this works for you.
encodedBytes = base64.b64encode(input_var_1)base64_item_var = str(encodedBytes, "utf-8")
0 -
Hi, sorry for the bad news but using ION to call IDM APIs to create documents is not a best practice and definitely not recommended or advised - in most scenarios it will cause the owner of the tenant to breach their licence limits. ION is intended as we all know for async data processing using mainly XML and JSON - where there is a size limit on the messages of 5MB, hard enforced in some activities like the script engine for technical reasons. When document. images, etc. are sent in to ION, especially using b64 encoding then they normally exceed these limits and will either fail in the flow or cause the user to be over their limits - hence it should not be used for this purpose.
The correct way to do this would be to called the IDM API directly from the outside world, whatever is triggering the ION flow in the first place should basically call the IDM APIs directly - that will be far more efficient, both in terms of performance and in use of the licence.
If the outside system is not capable of calling an API directly then you could look to use BaaS (Backend as a Service) capabilities to orchestrate all this in a way that is scalable and valid - of course BaaS is not part of the core OS tier in MT and so would required an add-on - but is hugely powerful for many complex use cases. In this design, ION might still play a part for triggering things but not actually carrying the load
sorry to be the bearer of bad news for you
10
Answers
-
Hi Brandon,
It works perfectly and also with a Binary typed parameter (instead of String) for the python fusion script.
Thanks you very much
0