mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 15:07:49 +00:00
feat: add support for png
feat: add tests chore: update dependencies
This commit is contained in:
parent
f1fafe7ef0
commit
b4dea89fad
6 changed files with 250 additions and 94 deletions
|
|
@ -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
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue