original_string: public function sendFile($file, $contentType = false) {
          $fp = fopen($file, "r");
          $this['response']->setBody(new \Guzzle\Stream\Stream($fp));
          if ($contentType) {
              $this['response']->setHeader("Content-Type", $contentType);
          } else {
              if (file_exists($file)) {
                  //Set Content-Type
                  if (extension_loaded('fileinfo')) {
                      $finfo = new \finfo(FILEINFO_MIME_TYPE);
                      $type = $finfo->file($file);
                      $this['response']->setHeader("Content-Type", $type);
                  } else {
                      $this['response']->setHeader("Content-Type", "application/octet-stream");
                  }
  
                  //Set Content-Length
                  $stat = fstat($fp);
                  $this['response']->setHeader("Content-Length", $stat['size']);
              } else {
                  //Set Content-Type and Content-Length
                  $data = stream_get_meta_data($fp);
  
                  foreach ($data['wrapper_data'] as $header) {
                      list($k, $v) = explode(": ", $header, 2);
  
                      if ($k === "Content-Type") {
                          $this['response']->setHeader("Content-Type", $v);
                      } else if ($k === "Content-Length") {
                          $this['response']->setHeader("Content-Length", $v);
                      }
                  }
              }
          }
      }
code: public function sendFile($file, $contentType = false) {
          $fp = fopen($file, "r");
          $this['response']->setBody(new \Guzzle\Stream\Stream($fp));
          if ($contentType) {
              $this['response']->setHeader("Content-Type", $contentType);
          } else {
              if (file_exists($file)) {
                  //Set Content-Type
                  if (extension_loaded('fileinfo')) {
                      $finfo = new \finfo(FILEINFO_MIME_TYPE);
                      $type = $finfo->file($file);
                      $this['response']->setHeader("Content-Type", $type);
                  } else {
                      $this['response']->setHeader("Content-Type", "application/octet-stream");
                  }
  
                  //Set Content-Length
                  $stat = fstat($fp);
                  $this['response']->setHeader("Content-Length", $stat['size']);
              } else {
                  //Set Content-Type and Content-Length
                  $data = stream_get_meta_data($fp);
  
                  foreach ($data['wrapper_data'] as $header) {
                      list($k, $v) = explode(": ", $header, 2);
  
                      if ($k === "Content-Type") {
                          $this['response']->setHeader("Content-Type", $v);
                      } else if ($k === "Content-Length") {
                          $this['response']->setHeader("Content-Length", $v);
                      }
                  }
              }
          }
      }
code_tokens: public function sendFile ( $ file , $ contentType = false ) { $ fp = fopen ( $ file , "r" ) ; $ this [ 'response' ] -> setBody ( new \ Guzzle \ Stream \ Stream ( $ fp ) ) ; if ( $ contentType ) { $ this [ 'response' ] -> setHeader ( "Content-Type" , $ contentType ) ; } else { if ( file_exists ( $ file ) ) { //Set Content-Type if ( extension_loaded ( 'fileinfo' ) ) { $ finfo = new \ finfo ( FILEINFO_MIME_TYPE ) ; $ type = $ finfo -> file ( $ file ) ; $ this [ 'response' ] -> setHeader ( "Content-Type" , $ type ) ; } else { $ this [ 'response' ] -> setHeader ( "Content-Type" , "application/octet-stream" ) ; } //Set Content-Length $ stat = fstat ( $ fp ) ; $ this [ 'response' ] -> setHeader ( "Content-Length" , $ stat [ 'size' ] ) ; } else { //Set Content-Type and Content-Length $ data = stream_get_meta_data ( $ fp ) ; foreach ( $ data [ 'wrapper_data' ] as $ header ) { list ( $ k , $ v ) = explode ( ": " , $ header , 2 ) ; if ( $ k === "Content-Type" ) { $ this [ 'response' ] -> setHeader ( "Content-Type" , $ v ) ; } else if ( $ k === "Content-Length" ) { $ this [ 'response' ] -> setHeader ( "Content-Length" , $ v ) ; } } } } }
docstring: Send a File
  
  This method streams a local or remote file to the client
  
  @param  string $file        The URI of the file, can be local or remote
  @param  string $contentType Optional content type of the stream, if not specified Slim will attempt to get this
  @api
docstring_tokens: Send a File