fix paths

This commit is contained in:
2026-05-07 21:18:50 +03:00
parent 639ee895cd
commit 48e32bfdcb
12 changed files with 74 additions and 51 deletions
+14 -11
View File
@@ -4,16 +4,13 @@ namespace Lucent\File;
use Illuminate\Contracts\Filesystem\Filesystem;
use Illuminate\Http\UploadedFile;
use Illuminate\Log\Logger;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Intervention\Image\ImageManager;
use Lucent\Channel\ChannelService;
use Lucent\Database\Database;
use Lucent\Id\Id;
use Lucent\LucentException;
use Lucent\Data\File as DataFile;
use Lucent\Record\QueryRecord;
use Spatie\ImageOptimizer\OptimizerChainFactory;
class FileService
@@ -21,7 +18,6 @@ class FileService
public function __construct(
public ChannelService $channelService,
public ImageManager $imageManager,
public Logger $logger,
) {}
public function createFromUrl(
@@ -58,10 +54,10 @@ class FileService
$checksum = sha1_file($file);
$disk = $this->loadDisk();
$disk = $this->loadPublicDisk();
$path = "files/" . $recordId . "/" . $filename;
$res = $disk->put(
$path,
"lucent/" . $path,
file_get_contents($file),
// 'public' // now managed by aws policy
);
@@ -117,22 +113,29 @@ class FileService
return in_array($mimetype, $imageMimes);
}
public function loadDisk(): Filesystem
public static function loadPublicDisk(): Filesystem
{
return Storage::disk(config("lucent.disk"));
return Storage::disk(config("lucent.public_disk"));
}
public static function loadPrivateDisk(): Filesystem
{
return Storage::disk(config("lucent.private_disk"));
}
public function createTemplates(Filesystem $disk, string $path): void
{
$originalImage = $this->imageManager->make($disk->get($path));
$originalImage = $this->imageManager->make(
$this->loadPublicDisk()->get("lucent/" . $path),
);
foreach (config("lucent.imageFilters") as $preset => $filterClass) {
$imageClone = clone $originalImage;
$image = $imageClone->filter(new $filterClass());
$templateUri = "/templates/" . $preset . "/" . $path;
$templateUri = "lucent/templates/" . $preset . "/" . $path;
$disk->put($templateUri, $image->encode("webp", 75));
}
$thumbDir = "thumbs/" . $path;
$thumbDir = "lucent/thumbs/" . $path;
$image = $originalImage->fit(300, 300);
$disk->put($thumbDir, $image->encode("webp", 75));