Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE OR REPLACE FUNCTION inventory.sha1_to_url( IN sha1 text, IN url_base text, IN content_type text, OUT text ) AS $$
- use URI;
- my ( $sha1, $url, $ct ) = @_;
- my ( $d1, $d2, $xs ) = unpack "A2A2A*", $sha1;
- $url =~ /.*([.].+)$/;
- my $ext = $1;
- my $u = URI->new( $url );
- my $ext = 'jpg' if $ct =~ /jpe?g/;
- $u->path_segments( (split '/', $u->path), $d1, $d2, "$xs\.$ext" );
- return $u->canonical;
- $$ LANGUAGE plperlu STRICT IMMUTABLE;
Add Comment
Please, Sign In to add comment