cancel
Showing results for 
Search instead for 
Did you mean: 

How to unzip the file and convert into base64

Former Member
0 Kudos

Hi All,

I have a requirement in which I have to perform the following.

  • PI will receive a Zip file which contains 2 files (XML & JPG)
  • I need to convert the JPG into base64 and send the information to iDoc along with the XML information

Question

1) How to extract the zip files in SAP PI 7.0 sp18

2) How to process both the files i.e XML & JPG

3) How to convert JPG to Base64

Souce Structure

abc

def

jhi

Target Structure

abc

def

jhi

imagecode (base64)

Can somebody please guide me how to fulfil this requirement.

Thanks,

Iqbal

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member181985
Active Contributor
0 Kudos

Hi,

You should create a custom module to read the attachment and then convert it to base64 data.

PI7.0 does not support reading attachments in mapping pipeline step.

1) How to extract the zip files in SAP PI 7.0 sp18

Use payloadzip bean with unzip option. Search forum for more details on usage.

2) How to process both the files i.e XML & JPG

payloadzip bean will extract the documents as one main payload and remaining as attachments. You can also payload swap bean to ensure JPG as attachment. Use custom module to read the attachment and then formulate a fresh payload with XML and JPG base64 data.

3) How to convert JPG to Base64

Search forum, there are lot of documents available for this.

Regards,

Praveen

Former Member
0 Kudos

Hi Praveen,

Thanks for your quick reply.

2) How to process both the files i.e XML & JPG

payloadzip bean will extract the documents as one main payload and remaining as attachments. You can also payload swap bean to ensure JPG as attachment. Use custom module to read the attachment and then formulate a fresh payload with XML and JPG base64 data.

Could you please tell little more about this as I didn't really understand the module part.

Thanks,

Iqbal

former_member181985
Active Contributor
0 Kudos

2) How to process both the files i.e XML & JPG

  • Use payloadzip bean module in FileSender channel to unzip the file.
  • If required, Use Payloadswap bean module in File Sender, next in sequence to ensure JPG as attachment
  • Create a custom java adapter module which can read both payload and attachment and then form a fresh payload to have both XML data and base64 JPG data.
  • map this structure accordingly to idoc structure.

Search SCN for more details on standard module usage and custom module development/base64 conversion.

Regards,

Praveen Gujjeti