[EDIT] This is a valid answer to the memory allocation problem, but does not solve file upload within reasonable script memory usage constrains, which was the actual question. For an answer to that question, check out https://stackoverflow.com/a/14693917/1060686
PHP has a mechanism that prevents PHP scripts from using more memory than allowed by a given threshold. This threshold can be configured in the php.ini (for all scripts) or per script. I would advice to set it per script to a higher value.
On top of your script add the following line:
ini_set('memory_limit', '500M');
Explanation of large memory usage: You read the file using the following line:
$data = file_get_contents('myfile.zip');
This requires PHP to read the full file contents into memory ( in var $data
). It would be better to read the file blockwise e.g. in 4096 byte blocks and send them to network immediately. Like I said, I currently don't know if its possible using the google API that you are using.