title: WP_REST_Response to download a file
body: <p>Is it possibile to return a document (a generated PDF, a CSV) using the <code>WP_REST_Response</code> in WordPress?</p>
  
  <p>So far I've been registering a custom endpoint using <code>register_rest_resource</code> but if I try to return a file (e.g. using PHP <code>fpassthru($f)</code> or <code>readfile($f)</code> I get the "Headers already sent" error.</p>
  
  <p>Using other words: how you would return a file using Wordpress REST APIs?</p>
  
  <p>Any help is appreciated!</p>
  
  <p>Thanks</p>