Skip to content

Commit 430478a

Browse files
committed
fix routing of non-public files
1 parent 9f80548 commit 430478a

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/controllers/RedirectController.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@
1010
*/
1111
class RedirectController extends LfmController
1212
{
13+
private $file_path;
14+
15+
public function __construct()
16+
{
17+
$delimiter = config('lfm.prefix') . '/';
18+
$url = request()->url();
19+
// dd($delimiter);
20+
$external_path = substr($url, strpos($url, $delimiter) + strlen($delimiter));
21+
22+
$this->file_path = base_path(config('lfm.base_directory', 'public') . '/' . $external_path);
23+
}
24+
1325
/**
1426
* Get image from custom directory by route
1527
*
@@ -18,7 +30,7 @@ class RedirectController extends LfmController
1830
*/
1931
public function getImage($base_path, $image_name)
2032
{
21-
return $this->responseImageOrFile($image_name);
33+
return $this->responseImageOrFile();
2234
}
2335

2436
/**
@@ -31,12 +43,12 @@ public function getFile(Request $request, $base_path, $file_name)
3143
{
3244
$request->request->add(['type' => 'Files']);
3345

34-
return $this->responseImageOrFile($file_name);
46+
return $this->responseImageOrFile();
3547
}
3648

37-
private function responseImageOrFile($file_name)
49+
private function responseImageOrFile()
3850
{
39-
$file_path = parent::getCurrentPath($file_name);
51+
$file_path = $this->file_path;
4052

4153
if (!File::exists($file_path)) {
4254
abort(404);

0 commit comments

Comments
 (0)