PHP Looping uploads

62 views Asked by At

I'm uploading files into Rackspace Cloud Files and, unfortunately, they have a limit of 100 uploads/second per container, so what I'm trying to do is, if the upload fails, try again until the upload succeeds.

// uploading a local file on the server...

do {
    $container = $objectStoreService->getContainer($container_name);
    $localFileName  = $filepath;
    $remoteFileName = $hash.'-'.$filename;
    $handle = fopen($localFileName, 'r');
} while (!$object = $container->uploadObject($remoteFileName, $handle));

Using the above code block and ApacheBench unit testing I'm only getting a little better than 50% of the files uploaded, so obviously I'm doing something wrong.

Any suggestions as to what I'm doing wrong or how I can improve?

0

There are 0 answers