How to Upload large files into Google Cloud Storage?

1,241 views
Skip to first unread message

Tzahi Harary

unread,
Jun 13, 2022, 6:56:32 AM6/13/22
to Google Cloud Developers
Hello, I need a help with finding a sample PHP code that can upload large files (1GB+) to Google Cloud Storage service.
I have all the related services configured and connected.
I able to upload files with the following code I found at Google docs, but it breaks at the 128MB limit:
This is the limit on my shared hosting server. All the changes that I made to php.ini using cPanel can not bypass this 128MB limit.
I have another Wordpress website on the same server with a plugin that knows how to upload large files into Google Drive.
I wonder if you know a simple PHP class that can do the same with Google Cloud Storage?
I know that i' need to loop through the file and upload it in small chunks, but I don't know how to write it to work with the Google Cloud Storage API.
Thanks!

Rogelio Monter

unread,
Jun 14, 2022, 4:45:06 PM6/14/22
to Google Cloud Developers

The break at 128MB seems to be a PHP issue with the memory limit. You can increase the limit as shown on this StackOverflow answer. In this blog entry , there are other options that you should check.

After you have double checked that your server does not have those limits, this question on Stack Overflow suggests to 

upload the files in chunks using this package.

Also, as discussed in this answer, it is highly recommended to use Bucket::getResumableUploader().

This is a more technical or coding question, more appropriate for forums like StackOverflow, where experienced PHP programmers are ready to help with such issues. Groups are meant more for general discussions and opinions. 

Jamey Kirby

unread,
Jun 15, 2022, 7:38:02 PM6/15/22
to Rogelio Monter, Google Cloud Developers
Why not use gsutil?

--
You received this message because you are subscribed to the Google Groups "Google Cloud Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-d...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-dev/1585693f-44fe-4c82-89fc-abb20c56bc5dn%40googlegroups.com.

Rogelio Monter

unread,
Jun 16, 2022, 1:05:34 PM6/16/22
to Google Cloud Developers
Although uploading could be done using gsutil as shown on this post, the original question is about doing it using PHP as shown on this other post.
Reply all
Reply to author
Forward
0 new messages