daily pastebin goal
50%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 129 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE OR REPLACE FUNCTION inventory.sha1_to_url( IN sha1 text, IN url_base text, IN content_type text, OUT text ) AS $$
  2.   use URI;
  3.   my ( $sha1, $url, $ct ) = @_;
  4.  
  5.   my ( $d1, $d2, $xs ) = unpack "A2A2A*", $sha1;
  6.   $url =~ /.*([.].+)$/;
  7.   my $ext = $1;
  8.  
  9.   my $u = URI->new( $url );
  10.   my $ext = 'jpg' if $ct =~ /jpe?g/;
  11.   $u->path_segments( (split '/', $u->path), $d1, $d2, "$xs\.$ext" );
  12.  
  13.   return $u->canonical;
  14. $$ LANGUAGE plperlu STRICT IMMUTABLE;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top