[EDIT] 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 unanswered question: Upload large file to google drive with PHP Client Library
I'm trying to upload a big file (237MB) to my google drive account from my VPS using the PHP CLI script provided on google API's quickstart guide and I get the following error:
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
The script:
<?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->setClientId('MY_CLIENT_ID');
$client->setClientSecret('MY_CLIENT_SECRET');
$client->setRedirectUri('urn:ietf:wg:oauth:2.0:oob');
$client->setScopes(array('https://www.googleapis.com/auth/drive'));
$service = new Google_DriveService($client);
$authUrl = $client->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->authenticate($authCode);
$client->setAccessToken($accessToken);
//Insert a file
$file = new Google_DriveFile();
$file->setTitle('My zip file');
$file->setDescription('A test zip file');
$file->setMimeType('application/zip');
$data = file_get_contents('myfile.zip');
$createdFile = $service->files->insert($file, array(
'data' => $data,
'mimeType' => 'application/zip',
));
print_r($createdFile);
?>
top says I've got 787816k physical memory free (plus 2G cache), so I don't get where the problem is. Any clues?