/// <summary>Construct the Authorization header value for the specified request.</summary> /// <param name="request"></param> /// <returns></returns> /// <remarks>See http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html#ConstructingTheAuthenticationHeader for more.</remarks> HttpRequestMessage AuthenticateRequest(HttpRequestMessage request) { request.Headers.Add( "Authorization", AmazonUtils.AuthenticateRequestS3(request, this.accessKeyId, this.secretAccessKey) ); return(request); }
public BlobStore(string bucket, string subdir) { this.logger = Serilog.Log .ForContext(HoneycombSink.DatasetPropertyKey, "Storage") .ForContext("bucket", bucket) .ForContext("subdir", subdir); this.bucket = bucket; this.subdir = subdir; string accessKeyString; AmazonUtils.GetAuthInfo(out this.accessKeyId, out accessKeyString); this.secretAccessKey = Encoding.UTF8.GetBytes(accessKeyString); }
public async Task <ThumbnailResponse> GetThumbnail( Uri imageUri, bool skipChecks = false, Uri referrer = null ) { var requestMessage = new HttpRequestMessage { RequestUri = new Uri("https://kuehe1it30.execute-api.us-west-2.amazonaws.com/prod/thumbr"), Method = HttpMethod.Post, Content = new StringContent( JsonConvert.SerializeObject(new ThumbnailRequest { Dream = imageUri, SkipChecks = skipChecks, Referrer = referrer, }, Policies.SerializerSettings), System.Text.Encoding.UTF8, "application/json" ), Headers = { { "Date", DateTimeOffset.UtcNow.ToString("r") } }, }; await AmazonUtils.AuthenticateRequestV4( requestMessage, "us-west-2", "execute-api", this.accessKeyId, this.secretAccessKey ); using (HttpResponseMessage response = await client.SendAsync(requestMessage)) { if (!response.IsSuccessStatusCode) { string error = await response.Content.ReadAsStringAsync(); return(new ThumbnailResponse { OriginalUrl = imageUri, Error = JValue.CreateString(error) }); } return(JsonConvert.DeserializeObject <ThumbnailResponse>( await response.Content.ReadAsStringAsync(), Policies.SerializerSettings )); } }
public ThumbnailServiceClient() { AmazonUtils.GetAuthInfo(out this.accessKeyId, out this.secretAccessKey); }