Note that there are some explanatory texts on larger screens.

plurals
  1. POMemory allocation error on basic Google Drive PHP API upload script
    primarykey
    data
    text
    <p><strong>[EDIT]</strong> As the error specifies, my php.ini allocates 1GB of RAM per script (memory_limit = 1G), which should be more than enough, so I'm not asking how to increase or modify this limit. I just found out this question can be considered a duplicate of this other <strong>unanswered</strong> question: <a href="https://stackoverflow.com/questions/13808528/upload-large-file-to-google-drive-with-php-client-library">Upload large file to google drive with PHP Client Library</a></p> <p>I'm trying to upload a big file (237MB) to my google drive account from my VPS using the PHP CLI script provided on <a href="https://developers.google.com/drive/quickstart-php#step_1_enable_the_drive_api" rel="nofollow noreferrer">google API's quickstart guide</a> and I get the following error:</p> <pre><code>PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 316952783 bytes) in /var/www/google-api-php-client/src/service/Google_MediaFileUpload.php on line 135 </code></pre> <p>The script:</p> <pre><code>&lt;?php require_once 'google-api-php-client/src/Google_Client.php'; require_once 'google-api-php-client/src/contrib/Google_DriveService.php'; $client = new Google_Client(); // Get your credentials from the APIs Console $client-&gt;setClientId('MY_CLIENT_ID'); $client-&gt;setClientSecret('MY_CLIENT_SECRET'); $client-&gt;setRedirectUri('urn:ietf:wg:oauth:2.0:oob'); $client-&gt;setScopes(array('https://www.googleapis.com/auth/drive')); $service = new Google_DriveService($client); $authUrl = $client-&gt;createAuthUrl(); //Request authorization print "Please visit:\n$authUrl\n\n"; print "Please enter the auth code:\n"; $authCode = trim(fgets(STDIN)); // Exchange authorization code for access token $accessToken = $client-&gt;authenticate($authCode); $client-&gt;setAccessToken($accessToken); //Insert a file $file = new Google_DriveFile(); $file-&gt;setTitle('My zip file'); $file-&gt;setDescription('A test zip file'); $file-&gt;setMimeType('application/zip'); $data = file_get_contents('myfile.zip'); $createdFile = $service-&gt;files-&gt;insert($file, array( 'data' =&gt; $data, 'mimeType' =&gt; 'application/zip', )); print_r($createdFile); ?&gt; </code></pre> <p>top says I've got 787816k physical memory free (plus 2G cache), so I don't get where the problem is. Any clues?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload