inital commit
This commit is contained in:
32
app/Services/ManageFile.php
Normal file
32
app/Services/ManageFile.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class ManageFile
|
||||
{
|
||||
const DISK = 'public';
|
||||
const RESOURCE_DIR = 'resources';
|
||||
|
||||
public function uploadFile($file_path,$file_name,$content){
|
||||
Storage::disk(self::DISK)->put(self::RESOURCE_DIR.DIRECTORY_SEPARATOR.$file_path.DIRECTORY_SEPARATOR.$file_name,$content);
|
||||
|
||||
}
|
||||
|
||||
public function uploadHTML($file_path,$file_name,$content){
|
||||
Storage::disk(self::DISK)->put(self::RESOURCE_DIR.DIRECTORY_SEPARATOR.$file_path.DIRECTORY_SEPARATOR.$file_name,$content);
|
||||
}
|
||||
|
||||
public function getFile($file_path): string
|
||||
{
|
||||
if (!Storage::disk(self::DISK)->exists(self::RESOURCE_DIR.DIRECTORY_SEPARATOR.$file_path)) {
|
||||
return "";
|
||||
}
|
||||
return Storage::disk(self::DISK)->get(self::RESOURCE_DIR.DIRECTORY_SEPARATOR.$file_path);
|
||||
}
|
||||
|
||||
public function deleteFile($file_path){
|
||||
return Storage::disk(self::DISK)->delete(self::RESOURCE_DIR.DIRECTORY_SEPARATOR.$file_path);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user