My problem is the following:

  1. there is a third-party service A, to which code there is no access and no one will rewrite it. The service has a function that allows you to get a user's photo, with the syntax getPhoto (Long userID, HttpServletResponse response). Accordingly, the data is in response.getOutputStream ().

  2. there is my service B, which according to the schedule launches integration with service A. As part of the integration, you need to update the photo, i.e., take a new one from service A and replace the existing one in the repository (folder on disk)

Get a photo in a different way, except through the specified function - no. This raises the question: how do we get data from response.getOutputStream (), which returns a ServletOutputStream object, to receive data? Or perhaps there is a way to write them directly to a file?

Service B uses Spring-Boot.

It was experimentally established that a ServletOutputStream cannot be brought to ByteArrayOutputStream.

0