feat: add support for png

feat: add tests

chore: update dependencies
This commit is contained in:
Benjamin Nussbaum 2025-04-24 19:31:57 +02:00
parent f1fafe7ef0
commit b4dea89fad
6 changed files with 250 additions and 94 deletions

View file

@ -44,13 +44,17 @@ class FetchProxyCloudResponses implements ShouldQueue
$imageUrl = $response->json('image_url');
$filename = $response->json('filename');
parse_str(parse_url($imageUrl)['query'] ?? '', $queryParams);
$imageType = urldecode($queryParams['response-content-type'] ?? 'image/bmp');
$imageExtension = $imageType === 'image/png' ? 'png' : 'bmp';
\Log::info('Response data: '.$imageUrl);
if (isset($imageUrl)) {
try {
$imageContents = Http::get($imageUrl)->body();
if (! Storage::disk('public')->exists("images/generated/{$filename}.bmp")) {
if (! Storage::disk('public')->exists("images/generated/{$filename}.{$imageExtension}")) {
Storage::disk('public')->put(
"images/generated/{$filename}.bmp",
"images/generated/{$filename}.{$imageExtension}",
$imageContents
);
}