Browse Source

File upload

Samson Mutunga 6 months ago
parent
commit
a60e85b64e

+ 2 - 2
app/Http/Controllers/Controller.php

@@ -172,7 +172,7 @@ class Controller extends BaseController
 			$uid = Uuid::uuid6();
             $originalFileName = $file->getClientOriginalName();
 			$fileName = $uid . "." . $file->extension();
-			$tempPath = Storage::putFileAs($path, $file, $fileName);
+			$tempPath = Storage::disk('custom')->putFileAs($path, $file, $fileName);
             $data = [
                 'path' => $tempPath,
                 'fileName' => $fileName,
@@ -191,7 +191,7 @@ class Controller extends BaseController
     }
 
     public function downloadFileByPath($file, $path){
-        return Storage::response($path . '/' . $file);
+        return Storage::disk('custom')->response($path . '/' . $file);
     }
     public function viewUploadedFile(Request $request, $file){
         return $this->downloadFileByPath($file, BaseModel::FILE_PATH);

+ 3 - 3
app/Http/Services/EmailService.php

@@ -261,12 +261,12 @@ class EmailService
     }
 
     protected function getAttachmentFromStoragePath($path, $fileName){
-        if (Storage::exists($path)) {
+        if (Storage::disk('custom')->exists($path)) {
             return [
                 'fileName' => $fileName,
                 'name' => basename($path),
-                'contents' => Storage::get($path),
-                'mime' => Storage::mimeType($path),
+                'contents' => Storage::disk('custom')->get($path),
+                'mime' => Storage::disk('custom')->mimeType($path),
             ];
         }
     

+ 5 - 0
config/filesystems.php

@@ -53,6 +53,11 @@ return [
             'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
         ],
 
+        'custom' => [
+            'driver' => 'local',
+            'root' => '/usr/local/uploads',
+        ],
+
     ],
 
     /*