Source/NFX.Web/IO/FileSystem/S3/V4/S3V4Sign/S3V4Signer.cs
/// <summary>
/// Returns string representing S3V4 call in canonized form
/// </summary>
Returns string representing S3V4 call in canonized form
Returns string representing S3V4 call in canonized form
public static string GetCanonicalRequest(string method, Uri uri,
        IDictionary<string, string> headers, IDictionary<string, string> queryParameters = null,
        string hashedPayload = EMPTY_BODY_SHA256)
      {
        var sortedLoweredHeaders = (headers ?? new Dictionary<string, string>()).OrderBy(kvp => kvp.Key);
        string canonicalQueryString = string.Join(AND, (queryParameters ?? new Dictionary<string, string>())
          .OrderBy(kvp => Uri.EscapeDataString(kvp.Key))
          .Select(kvp => string.Format("{0}={1}", Uri.EscapeDataString(kvp.Key), Uri.EscapeDataString(kvp.Value))));
        string canonicalHeaderString = string.Concat(
          sortedLoweredHeaders.Select(kvp => string.Format("{0}:{1}\n", kvp.Key.ToLower(), kvp.Value.Trim())));
        string signedHeaders = string.Join(SEMICOLON, sortedLoweredHeaders.Select(kvp => kvp.Key.ToLower()));
        string r = string.Join(NEWLINE, method, uri.GetS3AbsoolutePath(),
          canonicalQueryString, canonicalHeaderString, signedHeaders, hashedPayload);
        return r;
      }
public static string GetCanonicalRequest ( string method , Uri uri , IDictionary < string , string > headers , IDictionary < string , string > queryParameters = null , string hashedPayload = EMPTY_BODY_SHA256 ) { var sortedLoweredHeaders = ( headers ?? new Dictionary < string , string > ( ) ) . OrderBy ( kvp => kvp . Key ) ; string canonicalQueryString = string . Join ( AND , ( queryParameters ?? new Dictionary < string , string > ( ) ) . OrderBy ( kvp => Uri . EscapeDataString ( kvp . Key ) ) . Select ( kvp => string . Format ( " " , Uri . EscapeDataString ( kvp . Key ) , Uri . EscapeDataString ( kvp . Value ) ) ) ) ; string canonicalHeaderString = string . Concat ( sortedLoweredHeaders . Select ( kvp => string . Format ( " \n " , kvp . Key . ToLower ( ) , kvp . Value . Trim ( ) ) ) ) ; string signedHeaders = string . Join ( SEMICOLON , sortedLoweredHeaders . Select ( kvp => kvp . Key . ToLower ( ) ) ) ; string r = string . Join ( NEWLINE , method , uri . GetS3AbsoolutePath ( ) , canonicalQueryString , canonicalHeaderString , signedHeaders , hashedPayload ) ; return r ; }
Returns string representing S3V4 call in canonized form
Returns string representing S3V4 call in canonized form
method
string
uri
Uri
headers
IDictionary<string, string>
queryParameters
IDictionary<string, string>
hashedPayload
string