Layer 7 API Management

Expand all | Collapse all

Extract binary attachment

Jump to Best Answer
  • 1.  Extract binary attachment

    Posted 06-14-2016 07:05 AM

    Hi Folks,

                     I am trying to extract the contents of the attachment in the request, but I am not able to read the attachment data.

    Request - I am sending an xml file & a jpg file as attachments.

    curl -i -X POST -F "data=@download.jpg" -F "data=@sample.xml" https://<IP>:<port>/test/attachments

     

     

    I am logging the below context variables in the policy. I am also able to see that gateway has identified that request has 2 attachments . But unable to view the attachment body-

    • request.parts.1.size - 8783
    • request.parts.2.size - 88
    • request.parts.1.body -
    • request.parts.2.body -
    • request.parts.1.contentType - image/jpeg
    • request.parts.2.contentType - application/octet-stream

     

     

    Thanks,

    Abhishek Subramanya



  • 2.  Re: Extract MIME attachment

    Posted 06-16-2016 04:12 AM

    I have an update on the question. I was trying different formats. Here is what I observe -

     

    Scenario

    Description

    Comments

    1

    Request with two xml files as attachments

    Gateway is able to extract contents of both attachments. No issues found.

    2

    One xml file & another binary JPEG file as attachments

    Gateway is able to extract contents of xml only. I am unable to lookup/extract the binary contents in any form.

     

     

    Thanks,

    Abhishek



  • 3.  Re: Extract binary attachment
    Best Answer

    Posted 06-20-2016 02:21 AM

    Hello,

    request.parts.x.body is for textual content, for bin data, try request.parts.x

    for more detail, please refer to,

    Message Layer Context Variables - CA API Gateway - 9.1 - CA Technologies Documentation

     

    Regards,

    Mark

     

     



  • 4.  Re: Extract binary attachment

    Posted 06-20-2016 06:38 AM

    Thanks Zhijun He. We were able extract the mainpart of multipart attachments.

     

    I do have a follow up question regarding the context variables available. I do not see a variable specifying the file name. Should it be separately passed as a multipart header?

     

    Thanks,

    Abhishek



  • 5.  Re: Extract binary attachment

    Posted 06-21-2016 01:06 AM

    as per the MIME format, yes.

    try ${response.parts.x.header.Content-Disposition}



  • 6.  RE: Re: Extract binary attachment

    Posted 8 days ago
    Guys anybody some info, on how to read the content of attachment in layer 7


  • 7.  Re: Extract binary attachment

    Posted 06-21-2016 03:22 AM

    Thanks again.  We got the file names with the above variable

     

    Thanks,

    Abhishek