I followed the StreamedResponse class. There the setContent method is implemented the same way.

The content should be a string. To set the file handle resource, there is the setHandle method.