original_string: public function send_file($file) {
          // First we create the 'resumable upload request'.
          $this->googleoauth->setHeader("Content-Length: 0");
          $this->googleoauth->setHeader("X-Upload-Content-Length: ". $file->get_filesize());
          $this->googleoauth->setHeader("X-Upload-Content-Type: ". $file->get_mimetype());
          $this->googleoauth->setHeader("Slug: ". $file->get_filename());
          $this->googleoauth->post(self::UPLOAD_URL);
  
          if ($this->googleoauth->info['http_code'] !== 200) {
              throw new moodle_exception('Cantpostupload');
          }
  
          // Now we http PUT the file in the location returned.
          $location = $this->googleoauth->response['Location'];
          if (empty($location)) {
              throw new moodle_exception('Nouploadlocation');
          }
  
          // Reset the curl object for actually sending the file.
          $this->reset_curl_state();
          $this->googleoauth->setHeader("Content-Length: ". $file->get_filesize());
          $this->googleoauth->setHeader("Content-Type: ". $file->get_mimetype());
  
          // We can't get a filepointer, so have to copy the file..
          $tmproot = make_temp_directory('googledocsuploads');
          $tmpfilepath = $tmproot.'/'.$file->get_contenthash();
          $file->copy_content_to($tmpfilepath);
  
          // HTTP PUT the file.
          $this->googleoauth->put($location, array('file'=>$tmpfilepath));
  
          // Remove the temporary file we created..
          unlink($tmpfilepath);
  
          if ($this->googleoauth->info['http_code'] === 201) {
              // Clear headers for further requests.
              $this->reset_curl_state();
              return true;
          } else {
              return false;
          }
      }
code: public function send_file($file) {
          // First we create the 'resumable upload request'.
          $this->googleoauth->setHeader("Content-Length: 0");
          $this->googleoauth->setHeader("X-Upload-Content-Length: ". $file->get_filesize());
          $this->googleoauth->setHeader("X-Upload-Content-Type: ". $file->get_mimetype());
          $this->googleoauth->setHeader("Slug: ". $file->get_filename());
          $this->googleoauth->post(self::UPLOAD_URL);
  
          if ($this->googleoauth->info['http_code'] !== 200) {
              throw new moodle_exception('Cantpostupload');
          }
  
          // Now we http PUT the file in the location returned.
          $location = $this->googleoauth->response['Location'];
          if (empty($location)) {
              throw new moodle_exception('Nouploadlocation');
          }
  
          // Reset the curl object for actually sending the file.
          $this->reset_curl_state();
          $this->googleoauth->setHeader("Content-Length: ". $file->get_filesize());
          $this->googleoauth->setHeader("Content-Type: ". $file->get_mimetype());
  
          // We can't get a filepointer, so have to copy the file..
          $tmproot = make_temp_directory('googledocsuploads');
          $tmpfilepath = $tmproot.'/'.$file->get_contenthash();
          $file->copy_content_to($tmpfilepath);
  
          // HTTP PUT the file.
          $this->googleoauth->put($location, array('file'=>$tmpfilepath));
  
          // Remove the temporary file we created..
          unlink($tmpfilepath);
  
          if ($this->googleoauth->info['http_code'] === 201) {
              // Clear headers for further requests.
              $this->reset_curl_state();
              return true;
          } else {
              return false;
          }
      }
code_tokens: public function send_file ( $ file ) { // First we create the 'resumable upload request'. $ this -> googleoauth -> setHeader ( "Content-Length: 0" ) ; $ this -> googleoauth -> setHeader ( "X-Upload-Content-Length: " . $ file -> get_filesize ( ) ) ; $ this -> googleoauth -> setHeader ( "X-Upload-Content-Type: " . $ file -> get_mimetype ( ) ) ; $ this -> googleoauth -> setHeader ( "Slug: " . $ file -> get_filename ( ) ) ; $ this -> googleoauth -> post ( self :: UPLOAD_URL ) ; if ( $ this -> googleoauth -> info [ 'http_code' ] !== 200 ) { throw new moodle_exception ( 'Cantpostupload' ) ; } // Now we http PUT the file in the location returned. $ location = $ this -> googleoauth -> response [ 'Location' ] ; if ( empty ( $ location ) ) { throw new moodle_exception ( 'Nouploadlocation' ) ; } // Reset the curl object for actually sending the file. $ this -> reset_curl_state ( ) ; $ this -> googleoauth -> setHeader ( "Content-Length: " . $ file -> get_filesize ( ) ) ; $ this -> googleoauth -> setHeader ( "Content-Type: " . $ file -> get_mimetype ( ) ) ; // We can't get a filepointer, so have to copy the file.. $ tmproot = make_temp_directory ( 'googledocsuploads' ) ; $ tmpfilepath = $ tmproot . '/' . $ file -> get_contenthash ( ) ; $ file -> copy_content_to ( $ tmpfilepath ) ; // HTTP PUT the file. $ this -> googleoauth -> put ( $ location , array ( 'file' => $ tmpfilepath ) ) ; // Remove the temporary file we created.. unlink ( $ tmpfilepath ) ; if ( $ this -> googleoauth -> info [ 'http_code' ] === 201 ) { // Clear headers for further requests. $ this -> reset_curl_state ( ) ; return true ; } else { return false ; } }
docstring: Sends a file object to google documents
  
  @param object $file File object
  @return boolean True on success
docstring_tokens: Sends a file object to google documents