App-bsky

 view release on metacpan or  search on metacpan

lib/App/bsky.pm  view on Meta::CPAN

                $displayName //= $profile->{displayName};
                $description //= $profile->{description};
            }
            if ( defined $avatar ) {
                if ( $avatar =~ m[^https?://] ) {
                    my ( $content, $headers ) = $bsky->at->http->get($avatar);
                    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');

lib/App/bsky.pm  view on Meta::CPAN

                    $self->say('failed to upload avatar');
                }
            }
            if ( defined $banner ) {
                if ( $banner =~ m[^https?://] ) {
                    my ( $content, $headers ) = $bsky->at->http->get($banner);
                    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');



( run in 1.452 second using v1.01-cache-2.11-cpan-524268b4103 )