App-bsky
view release on metacpan or search on metacpan
lib/App/bsky.pm view on Meta::CPAN
use Carp;
$content // confess 'failed to download avatar from ' . $avatar;
# TODO: check content type HTTP::Tiny and Mojo::UserAgent do this differently
$avatar = $bsky->uploadFile( $content, $headers->{'content-type'} );
}
elsif ( -e $avatar ) {
use Path::Tiny;
$avatar = path($avatar)->slurp_raw;
my $type = substr( $avatar, 0, 2 ) eq pack 'H*',
'ffd8' ? 'image/jpeg' : substr( $avatar, 1, 3 ) eq 'PNG' ? 'image/png' : 'image/jpeg'; # XXX: Assume it's a jpeg?
$avatar = $bsky->uploadFile( $avatar, $type );
}
else {
$self->err('unsure what to do with this avatar; does not seem to be a URL or local file');
}
if ($avatar) {
$self->say( 'uploaded avatar... %d bytes', $avatar->{size} );
}
else {
$self->say('failed to upload avatar');
lib/App/bsky.pm view on Meta::CPAN
use Carp;
$content // confess 'failed to download banner from ' . $banner;
# TODO: check content type HTTP::Tiny and Mojo::UserAgent do this differently
$banner = $bsky->uploadFile( $content, $headers->{'content-type'} );
}
elsif ( -e $banner ) {
use Path::Tiny;
$banner = path($banner)->slurp_raw;
my $type = substr( $banner, 0, 2 ) eq pack 'H*',
'ffd8' ? 'image/jpeg' : substr( $banner, 1, 3 ) eq 'PNG' ? 'image/png' : 'image/jpeg'; # XXX: Assume it's a jpeg?
$banner = $bsky->uploadFile( $banner, $type );
}
else {
$self->err('unsure what to do with this banner; does not seem to be a URL or local file');
}
if ($banner) {
$self->say( 'uploaded banner... %d bytes', $banner->{size} );
}
else {
$self->say('failed to upload banner');
( run in 1.371 second using v1.01-cache-2.11-cpan-df04353d9ac )