Browse Source

Merge branch 'staging' of https://git.oslog.id/ibnu/generic-ospro-backend into dev-wahyun

pull/1/head
wahyuun 9 months ago
parent
commit
3c4c695e00
  1. 16
      app/Http/Controllers/Controller.php

16
app/Http/Controllers/Controller.php

@ -16,6 +16,7 @@ use Illuminate\Support\Facades\Http;
use Laravel\Lumen\Routing\Controller as BaseController;
use RecursiveIteratorIterator;
use RecursiveDirectoryIterator;
use Exception;
class Controller extends BaseController
{
@ -61,10 +62,21 @@ class Controller extends BaseController
{
$directory = 'assets/' . urldecode($company_name);
if (!is_dir($directory)) {
return "Directory not found";
}
$size = 0;
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file) {
$size += $file->getSize();
try {
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file) {
$size += $file->getSize();
}
} catch (Exception $e) {
return "Error while calculating size: " . $e->getMessage();
}
return round($size / 1048576, 2);
}

Loading…
Cancel
Save