Open utterances-bot opened 3 months ago
Hello, I have the filter which wraps the upload file request and caches it's body, but when the controller method arguments are resolved, getParts ends up empty after it. It seems that reading inputstream is in conflict with reading file from the post multiparty/form-data requests, do you have any suggestion? I found workaround for this by manually setting multiparfilter with highest presedance, so getParts will be called before the filter for caching the request body. For this request, cached request body will be empty byte array, since calling getParts already consumed inputstream...
How to Record Request and Response Bodies in Sping Boot Applications - Spring Cloud
The stream itself cannot be read repeatedly. But you can make a copy of it when you read it, and then you can read it multiple times. Luckily, spring provides this tool class.
https://www.springcloud.io/post/2022-03/record-request-and-response-bodies/