예제 #1
0
        public static string GetPresignedUrl(GetPresignedUrlRequest request, IAwsCredential credential, DateTime now)
        {
            HttpMethod method = request.Method.Equals("GET") ? HttpMethod.Get : new HttpMethod(request.Method);

            // TODO: support version querystring

            return(SignerV4.GetPresignedUrl(
                       credential: credential,
                       scope: new CredentialScope(now, request.Region, AwsService.S3),
                       date: now,
                       expires: request.ExpiresIn,
                       method: method,
                       requestUri: new Uri(request.GetUrl()),
                       payloadHash: UnsignedPayload
                       ));
        }
예제 #2
0
        public static string GetPresignedUrl(GetPresignedUrlRequest request, IAwsCredential credential, DateTime now)
        {
            var scope = new CredentialScope(now, request.Region, AwsService.S3);

            var urlBuilder = StringBuilderCache.Aquire()
                             .Append("https://")
                             .Append(request.Host)
                             .Append('/')
                             .Append(request.BucketName)
                             .Append('/')
                             .Append(request.Key);

            // TODO: support version querystring

            var message = new HttpRequestMessage(new HttpMethod(request.Method), StringBuilderCache.ExtractAndRelease(urlBuilder));

            SignerV4.Default.Presign(credential, scope, now, request.ExpiresIn, message, "UNSIGNED-PAYLOAD");

            string signedUrl = message.RequestUri.ToString();

            return(signedUrl);
        }
예제 #3
0
        public string GetPresignedUrl(string key, TimeSpan expiresIn)
        {
            var request = new GetPresignedUrlRequest(client.Host, client.Region, bucketName, key, expiresIn);

            return(client.GetPresignedUrl(in request));
        }
예제 #4
0
 public static string GetPresignedUrl(GetPresignedUrlRequest request, IAwsCredential credential)
 {
     return(GetPresignedUrl(request, credential, DateTime.UtcNow));
 }
예제 #5
0
 public string GetPresignedUrl(GetPresignedUrlRequest request)
 {
     return(S3Helper.GetPresignedUrl(request, credential));
 }