mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-29 03:10:51 +00:00
get_items_under_shared_by_folder_id moved to HelperService.php
This commit is contained in:
@@ -19,28 +19,6 @@ class BrowseShareController extends Controller
|
|||||||
$this->helper = resolve(HelperService::class);
|
$this->helper = resolve(HelperService::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get folders and files
|
|
||||||
*
|
|
||||||
* @param $id
|
|
||||||
* @param $shared
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function get_items($id, $shared): array
|
|
||||||
{
|
|
||||||
$folders = Folder::where('user_id', $shared->user_id)
|
|
||||||
->where('parent_id', $id)
|
|
||||||
->sortable()
|
|
||||||
->get();
|
|
||||||
|
|
||||||
$files = File::where('user_id', $shared->user_id)
|
|
||||||
->where('folder_id', $id)
|
|
||||||
->sortable()
|
|
||||||
->get();
|
|
||||||
|
|
||||||
return [$folders, $files];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search public files
|
* Search public files
|
||||||
*
|
*
|
||||||
@@ -146,11 +124,11 @@ class BrowseShareController extends Controller
|
|||||||
$this->helper->check_item_access($id, $shared);
|
$this->helper->check_item_access($id, $shared);
|
||||||
|
|
||||||
// Get files and folders
|
// Get files and folders
|
||||||
list($folders, $files) = $this->get_items($id, $shared);
|
list($folders, $files) = $this->helper->get_items_under_shared_by_folder_id($id, $shared);
|
||||||
|
|
||||||
// Set thumbnail links for public files
|
// Set thumbnail links for public files
|
||||||
$files->map(function ($item) use ($token) {
|
$files->map(function ($file) use ($token) {
|
||||||
$item->setPublicUrl($token);
|
$file->setPublicUrl($token);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Collect folders and files to single array
|
// Collect folders and files to single array
|
||||||
|
|||||||
@@ -158,11 +158,10 @@ class FileSharingController extends Controller
|
|||||||
// Check if user can get directory
|
// Check if user can get directory
|
||||||
$this->helper->check_item_access($id, $shared);
|
$this->helper->check_item_access($id, $shared);
|
||||||
|
|
||||||
// Get files and folders
|
|
||||||
list($folders, $files) = $this->get_items($id, $shared);
|
|
||||||
|
|
||||||
// Collect folders and files to single array
|
// Collect folders and files to single array
|
||||||
return collect([$folders, $files])->collapse();
|
return collect(
|
||||||
|
$this->helper->get_items_under_shared_by_folder_id($id, $shared)
|
||||||
|
)->collapse();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class SharedFileAccessContentController extends Controller
|
|||||||
->firstOrFail();
|
->firstOrFail();
|
||||||
|
|
||||||
// Check file access
|
// Check file access
|
||||||
$this->helper->check_file_access($shared, $file);
|
$this->helper->check_guest_access_to_shared_items($shared, $file);
|
||||||
|
|
||||||
// Store user download size
|
// Store user download size
|
||||||
$shared
|
$shared
|
||||||
@@ -109,7 +109,7 @@ class SharedFileAccessContentController extends Controller
|
|||||||
->firstOrFail();
|
->firstOrFail();
|
||||||
|
|
||||||
// Check file access
|
// Check file access
|
||||||
$this->helper->check_file_access($shared, $file);
|
$this->helper->check_guest_access_to_shared_items($shared, $file);
|
||||||
|
|
||||||
// Store user download size
|
// Store user download size
|
||||||
$shared
|
$shared
|
||||||
|
|||||||
@@ -413,7 +413,7 @@ class FileManagerService
|
|||||||
$this->helper->check_user_storage_capacity($user_id, $file_size, $temp_filename);
|
$this->helper->check_user_storage_capacity($user_id, $file_size, $temp_filename);
|
||||||
|
|
||||||
// Create thumbnail
|
// Create thumbnail
|
||||||
$thumbnail = $this->helper->get_image_thumbnail('chunks/' . $temp_filename, $disk_file_name, $user_id);
|
$thumbnail = $this->helper->create_image_thumbnail('chunks/' . $temp_filename, $disk_file_name, $user_id);
|
||||||
|
|
||||||
// Move finished file from chunk to file-manager directory
|
// Move finished file from chunk to file-manager directory
|
||||||
$disk_local->move('chunks/' . $temp_filename, "files/$user_id/$disk_file_name");
|
$disk_local->move('chunks/' . $temp_filename, "files/$user_id/$disk_file_name");
|
||||||
@@ -422,7 +422,7 @@ class FileManagerService
|
|||||||
if (!is_storage_driver(['local'])) {
|
if (!is_storage_driver(['local'])) {
|
||||||
|
|
||||||
// Move file to external storage service
|
// Move file to external storage service
|
||||||
$this->helper->move_to_external_storage($disk_file_name, $thumbnail);
|
$this->helper->move_file_to_external_storage($disk_file_name, $thumbnail);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store user upload size
|
// Store user upload size
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
|
use App\Models\File;
|
||||||
use App\Models\Folder;
|
use App\Models\Folder;
|
||||||
use Aws\Exception\MultipartUploadException;
|
use Aws\Exception\MultipartUploadException;
|
||||||
use Aws\S3\MultipartUploader;
|
use Aws\S3\MultipartUploader;
|
||||||
@@ -75,7 +76,7 @@ class HelperService
|
|||||||
* @param $shared
|
* @param $shared
|
||||||
* @param $file
|
* @param $file
|
||||||
*/
|
*/
|
||||||
public function check_file_access($shared, $file): void
|
public function check_guest_access_to_shared_items($shared, $file): void
|
||||||
{
|
{
|
||||||
// Check by parent folder permission
|
// Check by parent folder permission
|
||||||
if ($shared->type === 'folder') {
|
if ($shared->type === 'folder') {
|
||||||
@@ -121,7 +122,7 @@ class HelperService
|
|||||||
* @param string $filename
|
* @param string $filename
|
||||||
* @param string|null $thumbnail
|
* @param string|null $thumbnail
|
||||||
*/
|
*/
|
||||||
function move_to_external_storage($filename, $thumbnail = null): void
|
function move_file_to_external_storage($filename, $thumbnail = null): void
|
||||||
{
|
{
|
||||||
$disk_local = Storage::disk('local');
|
$disk_local = Storage::disk('local');
|
||||||
|
|
||||||
@@ -188,7 +189,7 @@ class HelperService
|
|||||||
* @param string $user_id
|
* @param string $user_id
|
||||||
* @return string|null
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
function get_image_thumbnail($file_path, $filename, $user_id)
|
function create_image_thumbnail($file_path, $filename, $user_id)
|
||||||
{
|
{
|
||||||
$local_disk = Storage::disk('local');
|
$local_disk = Storage::disk('local');
|
||||||
|
|
||||||
@@ -251,6 +252,8 @@ class HelperService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Get image thumbnail for browser
|
||||||
|
*
|
||||||
* @param $file
|
* @param $file
|
||||||
* @param $user_id
|
* @param $user_id
|
||||||
* @return mixed
|
* @return mixed
|
||||||
@@ -266,4 +269,26 @@ class HelperService
|
|||||||
// Return image thumbnail
|
// Return image thumbnail
|
||||||
return Storage::download($path, $file->getRawOriginal('thumbnail'));
|
return Storage::download($path, $file->getRawOriginal('thumbnail'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all folders and files under the share record
|
||||||
|
*
|
||||||
|
* @param $id
|
||||||
|
* @param $shared
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function get_items_under_shared_by_folder_id($id, $shared): array
|
||||||
|
{
|
||||||
|
$folders = Folder::where('user_id', $shared->user_id)
|
||||||
|
->where('parent_id', $id)
|
||||||
|
->sortable()
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$files = File::where('user_id', $shared->user_id)
|
||||||
|
->where('folder_id', $id)
|
||||||
|
->sortable()
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return [$folders, $files];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user