Search code examples
phpamazon-web-servicesamazon-glacier

Sdk Glacier php timeout


after playing a bit an uploading some small test files I wanted to upload a bigger file, around 200 MB but I always get the timeout exception, then I tried to upload a 30 MB file and the same happens. I think the timeout is 30 seconds, it is possible to tell the glacier client to wait until the upload is done?

This is the code I use:

$glacier->uploadArchive(array(
            'vaultName'          => $vaultName,
            'archiveDescription' => $desc
            'body'               => $body
        ));

I have tested with other files and the same happens, then I tried with a small file of 4MB and the operation was successful, I thought that dividing the files and uploading them one by one, bu then again around the third one a timeout exception comes out.

I also tried the multiupload with the following code

$glacier = GlacierClient::factory(array(
            'key'    => 'key',
            'secret' => 'secret',
            'region' => Region::US_WEST_2
        ));

$multiupload = $glacier->initiateMultipartUpload(array(
    'vaultName' => 'vaultName',
    'partSize' => '4194304'
));

// An array for the suffixes of the tar file
foreach($suffixes as $suffix){
$contents = file_get_contents('file.tar.gz'.$suffix);
$glacier->uploadMultipartPart(array(
    'vaultName' => 'vaultName',
    'uploadId' => $multiupload->get('uploadId'),
    'body' => $contents
));
}


$result=$glacier->completeMultipartUpload(array(
    'vaultName' => 'vaultName',
    'uploadId' => $multiupload->get('uploadId'),
));

echo $result->get('archiveId');

It misses the parameter Range, I don't think I fully understand how this multi part upload works, but I think I will have the same timeout exception. So my question is as I said before. It is possible to tell the glacier client to wait until the upload is done?


Solution

  • This sounds suspiciously like a script timeout. Try

    set_time_limit (120);
    

    just inside of the foreach loop. This will give you a two minute PHP sanity timer for each of your multi-part files.