mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 08:12:15 +00:00
controller refactoring part 18
This commit is contained in:
33
src/App/Users/Actions/CheckStorageCapacityAction.php
Normal file
33
src/App/Users/Actions/CheckStorageCapacityAction.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Users\Actions;
|
||||
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class CheckStorageCapacityAction
|
||||
{
|
||||
/**
|
||||
* Check if user has enough space to upload file
|
||||
*/
|
||||
public function __invoke(
|
||||
string $user_id,
|
||||
int $file_size,
|
||||
string $temp_filename,
|
||||
): void {
|
||||
// Get user storage percentage and get storage_limitation setting
|
||||
$user_storage_used = user_storage_percentage($user_id, $file_size);
|
||||
|
||||
// Check if user can upload
|
||||
if (get_setting('storage_limitation') && $user_storage_used >= 100) {
|
||||
// Delete file
|
||||
Storage::disk('local')
|
||||
->delete("chunks/$temp_filename");
|
||||
|
||||
// Abort uploading
|
||||
// TODO: test pre exceed storage limit
|
||||
abort(423, 'You exceed your storage limit!');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user