added basic traffic meter for upload/download

This commit is contained in:
Peter Papp
2020-11-23 18:29:23 +01:00
parent fefc10afb8
commit cb417ea76d
7 changed files with 106 additions and 359 deletions
@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use App\FileManagerFolder;
use App\Http\Tools\Guardian;
use App\Share;
use App\User;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
@@ -84,6 +85,9 @@ class FileAccessController extends Controller
$this->check_file_access($shared, $file);
}
// Store user download size
$request->user()->record_download((int) $file->getRawOriginal('filesize'));
return $this->download_file($file);
}
@@ -113,6 +117,9 @@ class FileAccessController extends Controller
// Check file access
$this->check_file_access($shared, $file);
// Store user download size
User::find($shared->user_id)->record_download((int) $file->getRawOriginal('filesize'));
return $this->download_file($file);
}
@@ -58,6 +58,10 @@ class FileSharingController extends Controller
->first();
if ($image) {
// Store user download size
User::find($shared->user_id)->record_download((int) $image->getRawOriginal('filesize'));
return $this->show_image($image);
}
}
+3
View File
@@ -308,6 +308,9 @@ class Editor
'user_id' => $user_id,
];
// Store user upload size
$request->user()->record_upload($file_size);
// Return new file
return FileManagerFile::create($options);
}