AS2 Encode/Decode processing of PDF & ZIP files
Published Oct 16 2023 08:56 AM 999 Views

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:




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:


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


Same applies to PDF files:






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



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



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