IBM Integration Community Come for answers. Stay for best practices. All we’re missing is you. Join / Log in Ask a question
Hi all,I have created a Gatewayscript inside local:/// which decodes a base64 encoded pdf sent thorugh from API Connect and creates the pdf inside temporary folder in the filesystems.
I now want to call the pdf from temporary folder to APIC and set it to the response body of the API. Any ideas on how to go about this.
i am getting the following error:
Hi Jayprakash,I tried using this but it says the data used to transfer must be UTF-8 encoded.
i'll once on a .txt file and let you know
Getting a pdf file from the temporary or local file storage by using the fsmodule is not possile because all the files gets UTF-8 encoded when going in and out of datapower.
I think we need to look into it more to find a work around.
Have you tried a urlopen.open for the local file and assuming the file is found (HTTP 200) you can then use response.readAsBuffer to read the data and set it into context, for example, message.body. The buffer returned by readAsBuffer is exactly what was read, so as long as you don't attempt to change it using a toString() function (which would use utf-8 encoding) you should be fine. Don't forget to also update message.headers.content-type to application/pdf to match the content type of the payload.