2

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?

timgavin
  • 4,972
  • 4
  • 36
  • 48
  • My guess would be that uploadObject doesn't return false, but perhaps throws an exception? That would make a lot more sense to me. – Evert Dec 03 '14 at 22:03
  • @Evert You're correct. I did some research and that's exactly what it is. So now I'm trying to figure out how to go about doing this with a `try/catch`, `do/while` scenario... – timgavin Dec 04 '14 at 19:12

0 Answers0