diff --git a/app/Http/Controllers/Sharing/FileSharingController.php b/app/Http/Controllers/Sharing/FileSharingController.php index 321b39f5..fa0849b3 100644 --- a/app/Http/Controllers/Sharing/FileSharingController.php +++ b/app/Http/Controllers/Sharing/FileSharingController.php @@ -18,6 +18,7 @@ use App\FileManagerFolder; use App\FileManagerFile; use App\User; use App\Share; +use Illuminate\Support\Facades\Storage; class FileSharingController extends Controller { @@ -47,10 +48,51 @@ class FileSharingController extends Controller Cookie::queue('shared_token', $token, 43200); } + // Check if shared is image file and then show it + if ($shared->type === 'file' && ! $shared->protected) { + + $image = FileManagerFile::where('user_id', $shared->user_id) + ->where('type', 'image') + ->where('unique_id', $shared->item_id) + ->first(); + + if ($image) { + return $this->show_image($image); + } + } + // Return page index return view("index"); } + /** + * Get image from storage and show it + * + * @param $file + * @return \Symfony\Component\HttpFoundation\StreamedResponse + */ + private function show_image($file) + { + // Format pretty filename + $file_pretty_name = $file->name . '.' . $file->mimetype; + + // Get file path + $path = '/file-manager/' . $file->basename; + + // Check if file exist + if (!Storage::exists($path)) abort(404); + + $header = [ + "Content-Type" => Storage::mimeType($path), + "Content-Length" => Storage::size($path), + "Accept-Ranges" => "bytes", + "Content-Range" => "bytes 0-600/" . Storage::size($path), + ]; + + // Get file + return Storage::response($path, $file_pretty_name, $header); + } + /** * Check Password for protected item * diff --git a/app/Http/Controllers/User/AccountController.php b/app/Http/Controllers/User/AccountController.php index 07158d2a..6df745a9 100644 --- a/app/Http/Controllers/User/AccountController.php +++ b/app/Http/Controllers/User/AccountController.php @@ -28,10 +28,10 @@ class AccountController extends Controller ->first(); // Get folder tree - $tree = FileManagerFolder::with('folders:id,parent_id,unique_id,name') + $tree = FileManagerFolder::with(['folders.shared', 'shared:token,id,item_id,permission,protected']) ->where('parent_id', 0) ->where('user_id', $user->id) - ->get(['id', 'parent_id', 'unique_id', 'name']); + ->get(); return [ 'user' => $user->only(['name', 'email', 'avatar']), diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 84307b4c..dae1421f 100644 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -1,4 +1,19 @@ { "/js/main.js": "/js/main.js", - "/css/app.css": "/css/app.css" + "/css/app.css": "/css/app.css", + "/js/main.e46fa96cd6ffd39a4562.hot-update.js": "/js/main.e46fa96cd6ffd39a4562.hot-update.js", + "/js/main.f2d49bc1541da0f12970.hot-update.js": "/js/main.f2d49bc1541da0f12970.hot-update.js", + "/js/main.1eef99df4b0f12424803.hot-update.js": "/js/main.1eef99df4b0f12424803.hot-update.js", + "/js/main.5ddffc9a7b267188676c.hot-update.js": "/js/main.5ddffc9a7b267188676c.hot-update.js", + "/js/main.390ae60e2291b0dbccc3.hot-update.js": "/js/main.390ae60e2291b0dbccc3.hot-update.js", + "/js/main.6f2959aac5b1dece64a9.hot-update.js": "/js/main.6f2959aac5b1dece64a9.hot-update.js", + "/js/main.46741bd43cbaa6ee89b1.hot-update.js": "/js/main.46741bd43cbaa6ee89b1.hot-update.js", + "/js/main.273e3c85d127556c963f.hot-update.js": "/js/main.273e3c85d127556c963f.hot-update.js", + "/js/main.262acc9e6f3602846eb5.hot-update.js": "/js/main.262acc9e6f3602846eb5.hot-update.js", + "/js/main.340ad852bdc54fb22ddd.hot-update.js": "/js/main.340ad852bdc54fb22ddd.hot-update.js", + "/js/main.0f01b236243cc4d2ab64.hot-update.js": "/js/main.0f01b236243cc4d2ab64.hot-update.js", + "/js/main.bc5704d8e53dc4abc11a.hot-update.js": "/js/main.bc5704d8e53dc4abc11a.hot-update.js", + "/js/main.d639deb26abe56ea8a48.hot-update.js": "/js/main.d639deb26abe56ea8a48.hot-update.js", + "/js/main.4a2927afd0488259ade3.hot-update.js": "/js/main.4a2927afd0488259ade3.hot-update.js", + "/js/main.11e163fdc882ac0dd7c2.hot-update.js": "/js/main.11e163fdc882ac0dd7c2.hot-update.js" } diff --git a/resources/js/components/FilesView/DesktopToolbar.vue b/resources/js/components/FilesView/DesktopToolbar.vue index 317f0ccc..8763ff91 100644 --- a/resources/js/components/FilesView/DesktopToolbar.vue +++ b/resources/js/components/FilesView/DesktopToolbar.vue @@ -37,7 +37,7 @@ :action="$t('actions.create_folder')" /> - +