configurable disks
This commit is contained in:
+10
-11
@@ -14,7 +14,6 @@ use Lucent\LucentException;
|
||||
use Lucent\Record\FileData as RecordFile;
|
||||
use Lucent\Record\QueryRecord;
|
||||
use Lucent\Schema\FilesSchema;
|
||||
use Lucent\Schema\Schema;
|
||||
use Spatie\ImageOptimizer\OptimizerChainFactory;
|
||||
|
||||
class FileService
|
||||
@@ -28,7 +27,7 @@ class FileService
|
||||
|
||||
public function getPath(QueryRecord $file): string
|
||||
{
|
||||
return $this->channelService->channel->url . "/storage/" . $file->_file->path;
|
||||
return $this->channelService->channel->filesUrl . "/" . $file->_file->path;
|
||||
}
|
||||
|
||||
public function createFromUrl(FilesSchema $schema, string $url): FileUploadResult
|
||||
@@ -111,15 +110,16 @@ class FileService
|
||||
|
||||
public function loadDisk(): Filesystem
|
||||
{
|
||||
return Storage::disk('lucent');
|
||||
return Storage::build([
|
||||
'driver' => 'local',
|
||||
'driver' => 'lucent',
|
||||
// 'key' => config("filesystems.disks.s3.key"),
|
||||
// 'secret' => config("filesystems.disks.s3.secret"),
|
||||
// 'region' => config("filesystems.disks.s3.region"),
|
||||
// 'bucket' => config("filesystems.disks.s3.bucket"),
|
||||
// // 'url' => $schema->objectStorageUrl,
|
||||
// 'endpoint' => $schema->objectStorageEndpoint,
|
||||
'use_path_style_endpoint' => false,
|
||||
// 'use_path_style_endpoint' => false,
|
||||
'visibility' => 'public', // now managed by aws policy
|
||||
'root' => storage_path('app/public'),
|
||||
'throw' => true,
|
||||
@@ -140,12 +140,10 @@ class FileService
|
||||
|
||||
private function createThumbnail(Filesystem $disk, string $schemaPath, string $filename, UploadedFile $file): void
|
||||
{
|
||||
|
||||
|
||||
$thumbDir = storage_path("app/public/thumbs/" . $schemaPath . "/");
|
||||
if (!file_exists($thumbDir)) {
|
||||
make_dir_r($thumbDir);
|
||||
}
|
||||
$thumbDir = "thumbs/" . $schemaPath . "/";
|
||||
// if (!file_exists($thumbDir)) {
|
||||
// make_dir_r($thumbDir);
|
||||
// }
|
||||
|
||||
try {
|
||||
ImageManagerStatic::configure(['driver' => 'imagick']);
|
||||
@@ -157,7 +155,8 @@ class FileService
|
||||
|
||||
$image->fit(300, 300);
|
||||
try {
|
||||
$image->encode('webp', 75)->save($thumbDir . $filename);
|
||||
$this->loadDisk()->put($thumbDir . $filename, $image->encode('webp', 75));
|
||||
// $image->encode('webp', 75)->save($thumbDir . $filename);
|
||||
} catch (Exception $e) {
|
||||
logger($e->getMessage());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user