REST with stream result for large data

There is an issue to fetch a large data by rest api in TSV format, to do this, i need to write data into a stream and then put it out to the web. How to do this ?

This is exactly what happens when you download files using standard REST API (see Swagger UI). Take a look at the com.haulmont.restapi.controllers.FileDownloadController - the implementation is there. If there is no FileDescriptor for your data, then you’ll have to create a custom controller and write data to write to a stream in it. Follow this guide if you need an OAuth authentication for the custom controller: Creating Custom OAuth2 Protected Controllers - CUBA Platform. Developer’s Manual