Home > Software engineering >  PHP Uploads with loop array
PHP Uploads with loop array

Time:03-17

I'm uploading files into cloud files and, but they have a limit of 100 uploads/second per container, so what I'm trying to do is, if the upload fails, I tried again.

while (!$object = $container->uploadObject($remoteFile, $handle));{
  $container = $objectStoreService->getContainer($containerName);
  $localFile  = $filepath;
  $remoteFile = $hash.'-'.$filename;
  $handle = fopen($localFile, 'r');
}

Using this code block and unit testing; I'm only getting a little better than 50% of the files uploaded, where is my fault?

CodePudding user response:

Probably your uploadObject doesn't return false, but maybe throws an exception? You check this. If it doesn't work, you can say that.

You can use try/cath for this problem.

  • Related