public static HttpUrl presignV4 ( Request request , String region , String accessKey , String secretKey , int expires ) throws NoSuchAlgorithmException , InvalidKeyException { String contentSha256 = "UNSIGNED-PAYLOAD" ; DateTime date = DateFormat . AMZ_DATE_FORMAT . parseDateTime ( request . header ( "x-amz-date" ) ) ; Signer signer = new Signer ( request , contentSha256 , date , region , accessKey , secretKey , null ) ; signer . setScope ( ) ; signer . setPresignCanonicalRequest ( expires ) ; signer . setStringToSign ( ) ; signer . setSigningKey ( ) ; signer . setSignature ( ) ; return signer . url . newBuilder ( ) . addEncodedQueryParameter ( S3Escaper . encode ( "X-Amz-Signature" ) , S3Escaper . encode ( signer . signature ) ) . build ( ) ; }
Returns pre - signed HttpUrl object for given request region access key secret key and expires time .