title: Downloading zip files from google drive using SDK for PHP
body: <p>I have uploaded my site backup to google drive using Drive SDK for PHP <code>"google/apiclient": "^2.0"</code> it is working perfect in terms of uploading now I am trying to download that backed up files from drive using the same SDK but the issue is, on some servers it works perfect and on other server's it gives me <code>Header already sent issue</code>. I am making this a plugin for WordPress and involving header for downloading those files is not a good idea I know that but what should be the alternate of it. The code through I am downloading those files is as follow.</p>
  
  <pre><code>$tempID = Helper::getBackupById($backupID);
      $AT = Helper::get_Settings('google_token');
      $refreshToken = Helper::get_Settings('google_refresh_token');
  
      $client = new Google_Client();
      $client-&gt;setClientId('CLIENT ID');
      $client-&gt;setClientSecret('CLIENT_SECRET');
      $client-&gt;setScopes(array('https://www.googleapis.com/auth/drive'));
  
      $client-&gt;setAccessToken($AT);
  
      if ($client-&gt;isAccessTokenExpired()) {
          $request = $client-&gt;refreshToken($refreshToken);
          $newAT = $request['access_token'];
          $newRefreshToken = $request['refresh_token'];
          Helper::save_or_update_settings('google_token', $newAT);
          Helper::save_or_update_settings('google_refresh_token', $newRefreshToken);
          $client-&gt;setAccessToken($newAT);
      }
  
      $service = new Google_Service_Drive($client);
  
      $google_keys = unserialize($tempID[0]-&gt;google_keys);
      $parentId = $google_keys['g_folder'];
      $lists = $service-&gt;files-&gt;listFiles(array('q' =&gt; "'$parentId' in parents"));
  
      foreach ($lists as $list) {
          if (!is_dir(wp_upload_dir()['basedir'] . '/Restore')) {
              @mkdir(wp_upload_dir()['basedir'] . '/Restore', 0777);
          }
          $storeIn = wp_upload_dir()['basedir'] . '/Restore/' . $list-&gt;name . '.zip';
  
          $content = $service-&gt;files-&gt;get($list-&gt;id, array('alt' =&gt; 'media'));
  
          $headers = $content-&gt;getHeaders();
          foreach ($headers as $name =&gt; $values) {
              header($name . ': ' . implode(', ', $values));
          }
          header('Content-Disposition: attachment; filename="' . $tempID[0]-&gt;file . '"');
          $body = $content-&gt;getBody();
  
          while (!$body-&gt;eof()) {
              file_put_contents($storeIn, $body);
          }
  
          echo "Done.\n";
      }
  </code></pre>
  
  <p>Now, my question is that, Is there any other way of downloading those files without involving any header in it. If yes just the hint of it would help a lot.</p>