How to make API call after getting response from upstream

Hello, colleagues! I’m trying to implement uploading large files by the following scheme:

The problem is that I can’t send API requests to my backend service after getting a response from AWS S3:

In method ‘header-filter’ I can’t do it because cosockets are blocked at this phase.

There is a workaround with ngx.timer.at but as far as I understood it’s impossible to get a response from it.

I am also unable to use the method ‘response’ cause it enables request body buffering. Files can be really big, up to 10GB, and I think this is not a good idea to make some load on Kong filesystem.

  1. Maybe someone faced with such prblem and has a solution?
  2. Why a request body must be buffered in order to use method ‘response’? I saw the Kong code and understand that it’s impossible to disable this behaviour. Maybe it is a good feature request for future?