title: Google Drive API GuzzleHttp\Exception\RequestException
body: <p>Following the instructions for these topics:
  <a href="https://github.com/google/google-api-php-client/issues/788" rel="nofollow noreferrer">https://github.com/google/google-api-php-client/issues/788</a>
  <a href="https://developers.google.com/api-client-library/php/guide/media_upload" rel="nofollow noreferrer">https://developers.google.com/api-client-library/php/guide/media_upload</a></p>
  
  <p>I tried to fix the problem below and upload files to Google Drive:</p>
  
  <blockquote>
    <p>Fatal error: Uncaught GuzzleHttp\Exception\RequestException: cURL error 60: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (see <a href="http://curl.haxx.se/libcurl/c/libcurl-errors.html" rel="nofollow noreferrer">http://curl.haxx.se/libcurl/c/libcurl-errors.html</a>) in /<em>secret</em>/public_html/v5/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:187 Stack trace: #0 /<em>secret</em>/public_html/v5/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(150): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array) #1 /<em>secret</em>/public_html/v5/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(103): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory)) #2 /<em>secret</em>/public_html/v5/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php(43): GuzzleHttp\Handler\CurlFactory::fin in /<em>secret</em>/public_html/v5/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php on line 187</p>
  </blockquote>
  
  
  
  <p>Using the APIs in PHP, when the file is less than 5 MB, it does not show the error, however, files larger than this generate the above error. Is the problem the API or the certificate? Even installing it on my linux server the error continues, does anyone know how to fix this problem? Or have you ever faced something like that?</p>
  
  <p>Here is the code I'm using to upload up to 5 MB that is working.</p>
  
  <pre><code>&lt;?php
  
  $client = new Google_Client();
  $client-&gt;setAuthConfig("client_secret.json");
  $client-&gt;setIncludeGrantedScopes(true);
  $client-&gt;setAccessType("offline");
  $client-&gt;setAccessToken($access_token);
  
  $drive_service = new Google_Service_Drive($client);
  
  $mime_type = mime_content_type($uploadfile);
  
  $file = new Google_Service_Drive_DriveFile();
  $result = $drive_service-&gt;files-&gt;create($file, array(
      "data" =&gt; file_get_contents($uploadfile),
      "mimeType" =&gt; $mime_type,
      "uploadType" =&gt; "media"
  )); 
  </code></pre>
  
  <p>Following is the code I'm using to upload a larger 5 MB that is not working.</p>
  
  <pre><code>&lt;?php
  
  $client = new Google_Client();
  $client-&gt;setAuthConfig("client_secret.json");
  $client-&gt;setIncludeGrantedScopes(true);
  $client-&gt;setAccessType("offline");
  $client-&gt;setAccessToken($access_token);
  
  $drive_service = new Google_Service_Drive($client);
  
  $mime_type = mime_content_type($uploadfile);
  
  $file = new Google_Service_Drive_DriveFile();
  $file-&gt;title = $uploadname;
  $chunkSizeBytes = 1 * 1024 * 1024;
  
  $client-&gt;setDefer(true);
  $request = $drive_service-&gt;files-&gt;create($file); // insert
  
  $media = new Google_Http_MediaFileUpload($client, $request, $mime_type, null, true, $chunkSizeBytes);
  $media-&gt;setFileSize(filesize($uploadfile));
  
  $status = false;
  $handle = fopen($uploadfile, "rb");
  
  while (!$status &amp;&amp; !feof($handle)) {
      $chunk = fread($handle, $chunkSizeBytes);
      $status = $media-&gt;nextChunk($chunk);
  }
  
  $result = false;
  if($status != false) {
      $result = $status;
  }
  
  fclose($handle);
  
  $client-&gt;setDefer(false);
  </code></pre>