original_string: public function uploadFromStream($filename, $source, array $options = [])
      {
          if ( ! is_resource($source) || get_resource_type($source) != "stream") {
              throw InvalidArgumentException::invalidType('$source', $source, 'resource');
          }
  
          $destination = $this->openUploadStream($filename, $options);
          stream_copy_to_stream($source, $destination);
  
          return $this->getFileIdForStream($destination);
      }
code: public function uploadFromStream($filename, $source, array $options = [])
      {
          if ( ! is_resource($source) || get_resource_type($source) != "stream") {
              throw InvalidArgumentException::invalidType('$source', $source, 'resource');
          }
  
          $destination = $this->openUploadStream($filename, $options);
          stream_copy_to_stream($source, $destination);
  
          return $this->getFileIdForStream($destination);
      }
code_tokens: public function uploadFromStream ( $ filename , $ source , array $ options = [ ] ) { if ( ! is_resource ( $ source ) || get_resource_type ( $ source ) != "stream" ) { throw InvalidArgumentException :: invalidType ( '$source' , $ source , 'resource' ) ; } $ destination = $ this -> openUploadStream ( $ filename , $ options ) ; stream_copy_to_stream ( $ source , $ destination ) ; return $ this -> getFileIdForStream ( $ destination ) ; }
docstring: Writes the contents of a readable stream to a GridFS file.
  
  Supported options:
  
  * _id (mixed): File document identifier. Defaults to a new ObjectId.
  
  * chunkSizeBytes (integer): The chunk size in bytes. Defaults to the
  bucket's chunk size.
  
  * disableMD5 (boolean): When true, no MD5 sum will be generated for
  the stored file. Defaults to "false".
  
  * metadata (document): User data for the "metadata" field of the files
  collection document.
  
  @param string   $filename Filename
  @param resource $source   Readable stream
  @param array    $options  Stream options
  @return mixed ID of the newly created GridFS file
  @throws InvalidArgumentException if $source is not a GridFS stream
  @throws DriverRuntimeException for other driver errors (e.g. connection errors)
docstring_tokens: Writes the contents of a readable stream to a GridFS file .