-
Notifications
You must be signed in to change notification settings - Fork 51
Description
I am looping through multiple files and passing to a recursive function to to upload to a B2 bucket like so:
private function upload($client, $file, $fileInfo, $savePath)
{
try {
$client->upload([
'BucketName' => 'my-bucket-name',
'FileName' => $file->getId() . '/' . $fileInfo->getFilename(),
'Body' => fopen($savePath .'/' . $fileInfo->getFilename(), 'r')
]);
} catch (Exception $e) {
$this->upload($client, $file, $fileInfo, $savePath);
}
}
The problem is that with multiple file uploads it is expected behaviour for B2 to occasionally fail. See here for 'Uploading Large Files' and 'Code Structure' - https://www.backblaze.com/b2/docs/uploading.html
The error I get after several successful file uploads looks like this
In ErrorHandler.php line 36: Received error from B2: c002_v0001118_t0038 is too busy
The problem here is firstly that the real error and response code is hidden, and secondly even though I am in a try catch block, it doesn't catch the exception.
My question is how should I handle multiple large file uploads to handle these expected (and other) potential exceptions?
Thanks