AS2 Encode/Decode processing of PDF & ZIP files

  • Thread starter Thread starter mshboul
  • Start date Start date
M

mshboul

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:

617x967?v=v2.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:

505x53?v=v2.png

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

1429x56?v=v2.png

Same applies to PDF files:

600x225?v=v2.png





1176x40?v=v2.png



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

701x268?v=v2.png



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


1643x127?v=v2.png

Continue reading...
 
Back
Top