Implement creator studio and upload updates

This commit is contained in:
2026-04-04 10:12:02 +02:00
parent 1da7d3bf88
commit 0b216b7ecd
15107 changed files with 31206 additions and 626514 deletions

View File

@@ -32,6 +32,9 @@ class NovaCardBackgroundService
throw new RuntimeException('Nova card background processing requires Intervention Image.');
}
$sourcePath = $this->resolveUploadPath($file);
$binary = $this->readUploadedBinary($sourcePath);
$uuid = (string) Str::uuid();
$extension = strtolower($file->getClientOriginalExtension() ?: 'jpg');
$originalDisk = Storage::disk((string) config('nova_cards.storage.private_disk', 'local'));
@@ -43,9 +46,9 @@ class NovaCardBackgroundService
$processedPath = trim((string) config('nova_cards.storage.background_processed_prefix', 'cards/backgrounds/processed'), '/')
. '/' . $user->id . '/' . $uuid . '.webp';
$originalDisk->put($originalPath, file_get_contents($file->getRealPath()) ?: '');
$originalDisk->put($originalPath, $binary);
$image = $this->manager->read($file->getRealPath())->scaleDown(width: 2200, height: 2200);
$image = $this->manager->read($binary)->scaleDown(width: 2200, height: 2200);
$encoded = (string) $image->encode(new WebpEncoder(88));
$processedDisk->put($processedPath, $encoded);
@@ -57,8 +60,30 @@ class NovaCardBackgroundService
'height' => $image->height(),
'mime_type' => (string) ($file->getMimeType() ?: 'image/jpeg'),
'file_size' => (int) $file->getSize(),
'sha256' => hash_file('sha256', $file->getRealPath()) ?: null,
'sha256' => hash('sha256', $binary),
'visibility' => 'card-only',
]);
}
private function resolveUploadPath(UploadedFile $file): string
{
$path = $file->getRealPath() ?: $file->getPathname();
if (! is_string($path) || trim($path) === '' || ! is_readable($path)) {
throw new RuntimeException('Unable to resolve uploaded background path.');
}
return $path;
}
private function readUploadedBinary(string $path): string
{
$binary = @file_get_contents($path);
if ($binary === false || $binary === '') {
throw new RuntimeException('Unable to read uploaded background image.');
}
return $binary;
}
}