Hi Samuel,
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.
Regards,
Steve
------------------------------
Steve Linn
Senior Consulting I/T Specialist
IBM
------------------------------
Original Message:
Sent: Fri November 11, 2022 12:05 AM
From: Samuel Pius
Subject: How to call pdf set in temporary folder inside Datapower filesystems
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.
------------------------------
Samuel Pius
Original Message:
Sent: Tue August 30, 2022 09:58 AM
From: Jina K
Subject: How to call pdf set in temporary folder inside Datapower filesystems
@Samuel Pius - any update since your last response?
------------------------------
Jina K
Original Message:
Sent: Tue July 12, 2022 01:32 AM
From: Samuel Pius
Subject: How to call pdf set in temporary folder inside Datapower filesystems
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
------------------------------
Samuel Pius
Original Message:
Sent: Tue July 12, 2022 01:20 AM
From: Jayprakash Yadav
Subject: How to call pdf set in temporary folder inside Datapower filesystems
Hi,
You can try ('urlopen') module, I am pretty sure this should work for you.
https://www.ibm.com/docs/en/datapower-gateway/10.0.x?topic=apis-urlopen-module
------------------------------
Jayprakash Yadav
Original Message:
Sent: Mon July 11, 2022 07:43 AM
From: Samuel Pius
Subject: How to call pdf set in temporary folder inside Datapower filesystems
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:
{
"httpCode": "500",
"httpMessage": "Internal Server Error",
"moreInformation": "The 'temporary:///applicationTest.pdf' script file is not encoded in UTF-8. Invalid character at line 2, position 2."
}.
------------------------------
Samuel Pius
------------------------------