Webmethods - Retrieve PDF file from SFTP and encode

843 Views Asked by At

I am new to webmethods and need some guidance. I am tasked to read the PDF document from SFTP server and base64 encode it. I have managed to GET the file from SFTP location and now struggling to encode it. Below is the code snippet to read the file:

INVOKE pub.client.sftp:login
INVOKE pub.client.sftp:cd
INVOKE pub.client.sftp:ls
INVOKE pub.client.sftp:get
MAP

I later modified the code to include base64 encoding, no output is produced. Code is shown below:

INVOKE pub.client.sftp:login
INVOKE pub.client.sftp:cd
INVOKE pub.client.sftp:ls
INVOKE pub.client.sftp:get
INVOKE pub.string:base64Encode
MAP

when i debug the code, it executes SFTP GET and stops. No information about encoding.

enter image description here

enter image description here

Please guide me to achieve this requirement. Thank you for your help in advance.

2

There are 2 best solutions below

2
Michael Knoth On

The pub.string:base64Encode expect a byte[] Input, you can try to convert the stream to byte[] with pub.io:streamToBytes

0
alexringo On

Try something like this, Sequence after sftp:get, invoke the pub.io:streamToBytes and then invoke pub.string:base64Encode

Don't forget to map field in pipeline.