AS2 Encode/Decode processing of PDF & ZIP files
Published Oct 16 2023 08:56 AM 1,405 Views
Microsoft

For Some B2B integration scenarios, there is a need to Encode/Decode files and interchange them over stream

 

For the AS2 Encoding Action, content-type plays important role in correctly fulfilling such scenario

 

For normal files, such as text ones, the encoding action will correctly recognize the content type (text/plain), and the encoding/decoding will work fine.

 

However, for PDF files for example, the encoder will recognize the content type as (application/pdf), however, to encode the stream correctly, it needs to be (application/octet-stream)

 

Same applies to ZIP files, it will be recognized as (application/x-zip-compressed), however, to encode the stream correctly, it needs to be (application/octet-stream)

 

To demonstrate this, we have the below sample Logic App Workflow:

mshboul_1-1697460673366.png

 

 

It is a simple logic app, that will read the file from blob, apply encode/decode, and then upload the decoded message to blob container.

 

When running the above logic app, the content type for the encoder step will be taken from the blob content header, as can be seen in the Raw Input of the encode step:

mshboul_2-1697460820188.png

Comparing the uploaded file in the blob container reveals size difference between the source blob, and the decoded blob:

mshboul_3-1697460878279.png

Same applies to PDF files:

mshboul_4-1697460979610.png

 

 

mshboul_6-1697461011530.png

 

To avoid the above behavior, we need to override the content-type for the encoding step, as below:

mshboul_7-1697461124565.png

 

Once overridden, the files will be decoded successfully, and this can be seen from the file sizes.

mshboul_8-1697461404136.png

 

Co-Authors
Version history
Last update:
‎Oct 16 2023 08:55 AM
Updated by: