Skip to content

Commit

Permalink
Update DownloadBlobsCommand.php
Browse files Browse the repository at this point in the history
  • Loading branch information
kawax committed Nov 19, 2024
1 parent 4a67897 commit a551a59
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/Console/DownloadBlobsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,7 @@ public function handle(): int

$content = $response->body();

$type = getimagesizefromstring($content);
$ext = '';
if (is_array($type)) {
$ext = image_type_to_extension($type[2]);
if ($ext === false) {
$ext = '';
}
}
$ext = $this->ext($content);

$name = Str::slug($actor, dictionary: ['.' => '-', ':' => '-']);
$file = 'bluesky/download/'.$name.'/_blob/'.$cid.$ext;
Expand All @@ -100,4 +93,19 @@ public function handle(): int

return 0;
}

protected function ext($content): string
{
$type = data_get(getimagesizefromstring($content), 2);
if (! is_int($type)) {
return '';
}

$ext = image_type_to_extension($type);
if ($ext === false) {
return '';
}

return $ext;
}
}

0 comments on commit a551a59

Please sign in to comment.