I have the following script which works with small files, however fails when I try a huge file (4GB):
<?php
require 'vendor/autoload.php';
use Google\Cloud\Storage\StorageClient;
$storage = new StorageClient([
'keyFilePath' => 'keyfile.json',
'projectId' => 'storage-123456'
]);
$bucket = $storage->bucket('my-bucket');
$options = [
'resumable' => true,
'chunkSize' => 200000,
'predefinedAcl' => 'publicRead'
];
// Upload a file to the bucket.
$bucket->upload(
fopen('data/file.imgc', 'r'),
$options
);
?>
The error I receive is:
Fatal error: Uncaught exception 'Google\Cloud\Core\Exception\GoogleException' with message 'Upload failed. Please use this URI to resume your upload:
Any ideas how to upload a large file?
I've also tried the getResumableUploader():
$uploader = $bucket->getResumableUploader(fopen('data/file.imgc', 'r'), [
'name' => 'file.imgc'
]);
try {
$object = $uploader->upload();
} catch (GoogleException $ex) {
$resumeUri = $uploader->getResumeUri();
$object = $uploader->resume($resumeUri);
}
When navigating to the resume URI it returns "Method Not Allowed"