Hi Santhoshkumar,
I would agree with that. The 100MB would be multiplied as you'd have the entire payload (100MB+) and then when parsing it into a variable with just the specific part, and perhaps another 100MB if you created a variable with just the part body, so you would consume quite a lot of memory doing that. Also thanks for the link as I was unaware of it! It looks like someone published a blog post based on a sample I'd written for a specific customer years ago that they had enhanced to meet a specific requirement. Note that the blob sample is doing to toString() function so that has the potential of impacting non-utf8 attachments.
Best Regards,
Steve
------------------------------
Steve Linn
Senior Consulting I/T Specialist
IBM
------------------------------
Original Message:
Sent: Thu February 23, 2023 12:00 PM
From: santhoshkumar surisetty
Subject: json payload with attachment
i got your point and got reference below. what do you suggest if the attachment having more than 100mb .i think that it causes memory exhaustion and resources issues. I think that , it is better not to parse things right. i am recommending that it is better to be passthrough then downstream application which will parse it.
https://i8c.be/blog/2021/11/08/ibm-api-management-multipart-form-data-payloads/
------------------------------
santhoshkumar surisetty
Original Message:
Sent: Thu February 23, 2023 11:48 AM
From: Steve Linn
Subject: json payload with attachment
Hi Santhoshkumar,
There is nothing built-in unfortunately although that requirement has been raised as an enhancement request for the API Gateway which is being evaluated. If you need this for a v5 compatible gateway or presently with the API Gateway you'll need to read the entire payload and parse through it yourself. We've been getting this question asked a lot frequently. The problem is there are so many use cases of what you may want to do. In your case it sounds like you might have something like a payload like
--------------------------d74496d66958873eContent-Disposition: form-data; name="person"anonymous--------------------------d74496d66958873eContent-Disposition: form-data; name="myfile"; filename="myfile.json"Content-Type: application/json{"hello":"world"}--------------------------d74496d66958873e--
and you want to extract that simple JSON payload and act upon it? Other use cases have been to inspect the Content-Disposition headers, to potentially modify an attachment payload that is ascii such as the above and then put the form back together again, and I'm sure there are others. I modified the payload example from https://everything.curl.dev/http/multipart for the above example to see the structure of the multipart form. Parsing through this is a matter of getting the boundary from the content type header of the request, knowing that the payload starts and ends with a --
and then stepping through the payload with a series of indexOf and slice methods based upon the boundary to separate the boundary parts and within the boundary part separating the headers from the body based upon the two line feed characters that separate the headers from the payload, and then do what your requirement is for the part(s) you need.
Best Regards,
Steve
------------------------------
Steve Linn
Senior Consulting I/T Specialist
IBM
Original Message:
Sent: Thu February 23, 2023 11:20 AM
From: santhoshkumar surisetty
Subject: json payload with attachment
Hi Steve,
Thank you for reply. i don't have much experience working with attachments. do we have inbuilt parser for Multipart message to parse and give us parts.if you have reference for it . i really appreciate your inputs.
------------------------------
santhoshkumar surisetty
Original Message:
Sent: Tue December 27, 2022 02:20 PM
From: Steve Linn
Subject: json payload with attachment
Hi Santhoshkumar,
It sounds like you want to send a multi-part form request where the primary part is your JSON request and the secondary part is your attachment. There is an outstanding request for enhancement to better support this but for now you're responsible for reading the entire request and parsing out the parts if you need to inspect the JSON request for example. The same would hold true for a v10 invoke response multi-part message. If you don't need to inspect the message part(s) then I believe the message should pass through. What is your use case?
Best Regards,
Steve Linn
------------------------------
Steve Linn
Senior Consulting I/T Specialist
IBM
Original Message:
Sent: Mon December 19, 2022 12:41 PM
From: santhoshkumar surisetty
Subject: json payload with attachment
Hi ,
i would appreciate , if you provide example for sending json payload with attachment and process attachment received as part of json response message.
------------------------------
santhoshkumar surisetty
------------------------------