title: Content of uploaded file missing Google Drive
body: <p>Info:</p>
  
  <ul>
  <li>I'm using the PHP client library for Google API</li>
  <li>I've created a project in Google's Developer Console, for OAuth I use Service account as Application Type.</li>
  <li>I've used the code on pages <a href="https://developers.google.com/drive/v2/reference/files/insert#examples" rel="nofollow noreferrer">https://developers.google.com/drive/v2/reference/files/insert#examples</a> and <a href="https://developers.google.com/drive/v2/reference/permissions/insert#examples" rel="nofollow noreferrer">https://developers.google.com/drive/v2/reference/permissions/insert#examples</a></li>
  </ul>
  
  <p>I've made a short sample in which I upload a file to Google Drive using the credentials of the service account. Since the service account doesn't have a Drive UI (<a href="https://stackoverflow.com/questions/13293698/google-drive-api-upload-returns-file-id-title-but-document-does-not-exist-in-dri">Google Drive API Upload returns File ID/Title but document does not exist in Drive</a>), I've added permissions for my own account. This works fine. But when I open the file in Google Docs I don't see the content of the file I uploaded. Below is my code. In the file I want to upload the content is "Hello World!" but this is not present in the document on Google Drive. Any ideas on how to fix this?</p>
  
  <pre><code>        function insertFile($service, $title, $description, $parentId, $mimeType, $fileName) {
              print "&lt;br/&gt;Uploading file...&lt;br/&gt;";
              $file = new Google_Service_Drive_DriveFile();
              $file-&gt;setTitle($title);
              $file-&gt;setDescription($description);
              $file-&gt;setMimeType($mimeType);
  
              // Set the parent folder
              if ($parentId != null) {
                  $parent = new Google_Service_Drive_ParentReference();
                  $parent-&gt;setId($parentId);
                  $file-&gt;setParents(array($parent));
              }
  
              try {
                  $data = file_get_contents($fileName);
  
                  $createdFile = $service-&gt;files-&gt;insert($file, array(
                      'data' =&gt; $data,
                      'mimeType' =&gt; $mimeType
                  ));
  
                  $newFileId = $createdFile-&gt;getId();
  
                  // Give permission to my email so I can see the file in my Drive UI
                  $myEmail = "&lt;mygmail&gt;";
                  $userType = "user";
                  $userRole = "writer";
                  insertPermission($service, $newFileId, $myEmail, $userType, $userRole);
  
                  print "&lt;br/&gt;File uploaded successfully!";
                  downloadFile($service, $newFileId);
              } catch (Exception $e) {
                  print "&lt;br/&gt;An error occurred: " . $e-&gt;getMessage();
              }
          }
  
          function insertPermission($service, $fileId, $userToPermit, $typeOfUser, $role) {
              $newPermission = new Google_Service_Drive_Permission();
              $newPermission-&gt;setValue($userToPermit);
              $newPermission-&gt;setType($typeOfUser);
              $newPermission-&gt;setRole($role);
              try {
                  return $service-&gt;permissions-&gt;insert($fileId, $newPermission);
              } catch (Exception $e) {
                  print "&lt;br/&gt;Error occurred while attempting to permit " . $userToPermit . " to file.&lt;br/&gt;" . $e-&gt;getMessage();
              }
              return null;
          }
  
          $docTitle = "UploadTest4.txt";
          $docMimeType = "text/plain";
          $docToUpload = "document.txt";
          insertFile($service, $docTitle, null, null, $docMimeType, $docToUpload);
  </code></pre>