cancel
Showing results for 
Search instead for 
Did you mean: 

SAP PI/PO- REST to File - Download file from URL which comes in a field

0 Kudos

Hello Experts,

I am on PO 7.5 and working on a REST to File scenario.

Requirement: I need to download a file from a URL .The URL is sent in a field through the REST Call. See below example.

Example:

<Record>

FileName> TestFile1.pdf <FileName

URL>www.test.com/TestFile1.pdf <URL

</Record>

<Record>

FileName> TestFile2.pdf <FileName

URL> www.test.com/TestFile2.pdf <URL

</Record>

Desired Result: Download the 2 files (TestFile1.pdf and TestFile2.pdf) from the URL's from the URL field and drop it off in an FTP/SFTP server.

I am not a java expert/or an expert with module configuration. Can we do this using an UDF in the graphical mapping.

I see the support attachments option in the REST sender attachment. I am not sure if that is helpful for my scenario.

I checked all the blogs and I was not able to find one that suits my requirement.

Can please you guide me through the configuration process.

Thanks,

Chan

0 Kudos

Thanks Vinay for your input. Sorry for the late reply.

My requirement was exactly to download the files from S3 buckets and it is what Alexander mentioned below in his blog.

It worked without any issues.

Thanks,

Chan

Accepted Solutions (1)

Accepted Solutions (1)

arrezende
Active Participant
0 Kudos
Hello,

I recently created a post explaining how to download a file from amazon, it seems to be a scenario close to what you presented.

Or try using the FormatConversionBean module adapter that makes encoded/decoded files ... https://blogs.sap.com/2015/03/25/formatconversionbean-one-bean-to-rule-them-all/

Answers (3)

Answers (3)

0 Kudos

Thank you all for your valuable inputs.

Alexander's blog helped me solve the requirement.

vinaymittal
Contributor
0 Kudos

Was it able to help you?

sugata_bagchi2
Active Contributor
0 Kudos

Hello Har` Chan,
As your source XML message contains multiple records, so the link to download the files will be multiple and dynamic.

For a static url, you can get the files using a GET operation of the REST adapter.
Or you can also implement SOAP-AXIS , where you can use the TASK(Axis) protocol and the HTTPGetter class as connection parameter.You also need to use the parameter - enableREST as true.

But your source XML has multiple links, so I would say you can create a Java class with a method to get the file from url and save it in a string.

In your Java mapping method you can pass the number of records and that many times you can all the method to get the files.

you can call this Java method in your mapping to get all the files and append to a single file. Then you can use a 2nd step mapping to split the entire xml into multiple messages and can produce multiple files at target.
Though the above design is not a efficient one. In this way it will be hard to capture the each of the source file name. But you can still populate this using Dynamic configuration UDF.

Moreover, you have to download pdf files which is a binary non-xml file. So it will be too complex with the above approach

Thanks

Sugata